Merge "Move tmpwatch from cron.daily to actual root crontab"

This commit is contained in:
Zuul 2021-03-31 16:09:27 +00:00 committed by Gerrit Code Review
commit 0dbcbd18ad
1 changed files with 30 additions and 15 deletions

View File

@ -104,21 +104,36 @@ outputs:
deploy_steps_tasks: deploy_steps_tasks:
- name: configure tmpwatch on the host - name: configure tmpwatch on the host
when: step|int == 2 when: step|int == 2
copy: block:
dest: /etc/cron.daily/containers-tmpwatch - name: Push script
owner: root copy:
group: root dest: /usr/local/sbin/containers-tmpwatch
mode: 0755 owner: root
content: | group: root
#!/bin/sh mode: 0755
tmpwatch --nodirs \ content: |
-X "/var/log/containers/*/*log" \ #!/bin/sh
-X "/var/log/containers/*/*/*log" \ tmpwatch --nodirs \
-X "/var/log/containers/*/*err" \ -X "/var/log/containers/*/*log" \
{{ LogrotatePurgeAfterDays|int +1 }}d \ -X "/var/log/containers/*/*/*log" \
/var/log/containers/ 2>&1 | logger -t container-tmpwatch -X "/var/log/containers/*/*err" \
vars: {{ LogrotatePurgeAfterDays|int +1 }}d \
LogrotatePurgeAfterDays: {get_param: LogrotatePurgeAfterDays} /var/log/containers/ 2>&1 | logger -t container-tmpwatch
vars:
LogrotatePurgeAfterDays: {get_param: LogrotatePurgeAfterDays}
- name: Insert cronjob in root crontab
cron:
name: "Remove old logs"
special_time: "daily"
user: "root"
job: "/usr/local/sbin/containers-tmpwatch"
update_tasks: &tmpwatch_script_clean
- name: Ensure old cron.daily is absent
when: step|int == 1
file:
path: /etc/cron.daily/containers-tmpwatch
state: absent
upgrade_tasks: *tmpwatch_script_clean
# BEGIN DOCKER SETTINGS # BEGIN DOCKER SETTINGS
puppet_config: puppet_config:
config_volume: crond config_volume: crond