Skip to content

Commit 4bc168e

Browse files
authored
Add option to use strings when configuring logrotate (#673)
Resolves #672
1 parent 7a36c1b commit 4bc168e

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.24.3 (Unreleased)
4+
5+
ENHANCEMENTS:
6+
7+
- Allow strings in addition to a list when configuring `logrotate`.
8+
39
## 0.24.2 (October 3rd, 2023)
410

511
FEATURES:

defaults/main/logrotate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# Create custom logrotate config
33
nginx_logrotate_conf_enable: false
44
nginx_logrotate_conf:
5-
paths:
6-
- /var/log/nginx/*.log
7-
options:
5+
paths: /var/log/nginx/*.log # String or list of strings
6+
# - /var/log/nginx/*.log
7+
options: # daily # String or a list of strings
88
- daily
99
- missingok
1010
- rotate 14
1111
- compress
1212
- delaycompress
1313
- notifempty
14-
- create 0644 www-data adm # Changes nginx logs permissions
14+
- create 0644 www-data adm # Changes NGINX log permissions
1515
- sharedscripts

molecule/default/converge.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
nginx_service_timeout: 95
1717
nginx_logrotate_conf_enable: true
1818
nginx_logrotate_conf:
19-
paths:
20-
- /var/log/nginx/*.log
19+
paths: /var/log/nginx/*.log
2120
options:
2221
- daily
2322
- missingok

templates/logrotate/nginx.j2

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
{% for path in nginx_logrotate_conf.paths %}
1+
{% if nginx_logrotate_conf['paths'] is defined and nginx_logrotate_conf['paths'] is not mapping %}
2+
{% for path in nginx_logrotate_conf['paths'] if nginx_logrotate_conf['paths'] is not string %}
23
{{ path }}
4+
{% else %}
5+
{{ nginx_logrotate_conf['paths'] }}
36
{% endfor %}
7+
{%- endif %}
48
{
5-
{% for option in nginx_logrotate_conf.options %}
9+
{% if nginx_logrotate_conf['options'] is defined and nginx_logrotate_conf['options'] is not mapping %}
10+
{% for option in nginx_logrotate_conf['options'] if nginx_logrotate_conf['options'] is not string %}
611
{{ option }}
12+
{% else %}
13+
{{ nginx_logrotate_conf['options'] }}
714
{% endfor %}
15+
{%- endif %}
816
postrotate
917
{% if ansible_facts['os_family'] == "Debian" %}
1018
if [ -f /var/run/nginx.pid ]; then

0 commit comments

Comments
 (0)