logrotate: better rotation options
The extant "logrotate_daily" varaible doesn't really do anything and isn't used. Modify this to be able to set a range of rotation periods or a size. Update mirror rsync mirrors to rotate weekly, as often releases run overnight and it's a pain to reconstruct. Change-Id: I121dc5f4fe7f226b66d18b9ec39e7e3839be4d40
This commit is contained in:
parent
64e5f9235d
commit
d4a96a421b
@ -36,8 +36,20 @@ not an exhaustive list of directives (contributions are welcome).
|
|||||||
.. zuul:rolevar:: logrotate_rotate
|
.. zuul:rolevar:: logrotate_rotate
|
||||||
:default: 7
|
:default: 7
|
||||||
|
|
||||||
.. zuul:rolevar:: logrotate_daily
|
.. zuul:rolevar:: logrotate_frequency
|
||||||
:default: yes
|
:default: daily
|
||||||
|
|
||||||
|
One of ``hourly``, ``daily``, ``weekly``, ``monthly``, ``yearly``
|
||||||
|
or ``size``.
|
||||||
|
|
||||||
|
If choosing ``size``, :zuul:rolevar::`logrotate.logrotate_size` must
|
||||||
|
be specified
|
||||||
|
|
||||||
|
.. zuul:rolevar:: logrotate_size
|
||||||
|
:default: None
|
||||||
|
|
||||||
|
Size; e.g. 100K, 10M, 1G. Only when
|
||||||
|
:zuul:rolevar::`logrotate.logrotate_frequency` is ``size``.
|
||||||
|
|
||||||
.. zuul:rolevar:: logrotate_notifempty
|
.. zuul:rolevar:: logrotate_notifempty
|
||||||
:default: yes
|
:default: yes
|
||||||
|
@ -3,5 +3,6 @@ logrotate_copytruncate: yes
|
|||||||
logrotate_delaycompress: yes
|
logrotate_delaycompress: yes
|
||||||
logrotate_missingok: yes
|
logrotate_missingok: yes
|
||||||
logrotate_rotate: 7
|
logrotate_rotate: 7
|
||||||
logrotate_daily: yes
|
logrotate_frequency: daily
|
||||||
|
logrotate_size: None
|
||||||
logrotate_notifempty: yes
|
logrotate_notifempty: yes
|
@ -3,6 +3,17 @@
|
|||||||
msg: Must set logrotate_file_name for logfile to rotate
|
msg: Must set logrotate_file_name for logfile to rotate
|
||||||
when: logrotate_file_name is not defined
|
when: logrotate_file_name is not defined
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- logrotate_frequency in ('hourly', 'daily', 'weekly', 'monthly', 'yearly', 'size')
|
||||||
|
fail_msg: Invalid logrotate_frequency
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- logrotate_size
|
||||||
|
fail_msg: Must specify size for rotation
|
||||||
|
when: logrotate_frequency == 'size'
|
||||||
|
|
||||||
# Hash the full path to avoid any conflicts but remain idempotent.
|
# Hash the full path to avoid any conflicts but remain idempotent.
|
||||||
# "/var/log/ansible/ansible.log" becomes "ansible.log.37237.conf" for example
|
# "/var/log/ansible/ansible.log" becomes "ansible.log.37237.conf" for example
|
||||||
- name: Create a unique config name
|
- name: Create a unique config name
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
missingok
|
missingok
|
||||||
{% endif %}
|
{% endif %}
|
||||||
rotate {{ logrotate_rotate }}
|
rotate {{ logrotate_rotate }}
|
||||||
{% if logrotate_daily %}
|
{% if logrotate_frequency != "size" %}
|
||||||
daily
|
{{ logrotate_frequency }}
|
||||||
|
{% else %}
|
||||||
|
size {{ logrotate_size }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if logrotate_notifempty %}
|
{% if logrotate_notifempty %}
|
||||||
notifempty
|
notifempty
|
||||||
|
@ -53,4 +53,5 @@
|
|||||||
name: logrotate
|
name: logrotate
|
||||||
vars:
|
vars:
|
||||||
logrotate_file_name: '/var/log/rsync-mirrors/{{ item }}.log'
|
logrotate_file_name: '/var/log/rsync-mirrors/{{ item }}.log'
|
||||||
|
logrotate_frequency: 'weekly'
|
||||||
loop: '{{ rsync_update_scripts }}'
|
loop: '{{ rsync_update_scripts }}'
|
Loading…
Reference in New Issue
Block a user