
Add a logrotate role that allows basic configuration of a logrotate configuration for a specific log-file. Use this role in the ansible-cron and install-ansible roles to ensure the log output they are generating is rotated. This role is not intended to manage the logrotate package (mostly to avoid the overhead of frequently checking package state when this is expected to be called for multiple configuration files on a server). We add it as a base package to our servers. Tests are added for testinfra. Change-Id: I90f59c3e42c1135d6be120de38e942ece608b761
27 lines
821 B
YAML
27 lines
821 B
YAML
- name: Ensure directory exists for lock files
|
|
file:
|
|
state: directory
|
|
path: /var/run/ansible
|
|
|
|
- name: Set PATH for cron
|
|
cron:
|
|
name: PATH
|
|
env: yes
|
|
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
- name: Set up cron job for running run_all.sh
|
|
cron:
|
|
name: run_all.sh
|
|
state: present
|
|
job: 'flock -n /var/run/ansible/run_all.lock bash /opt/system-config/run_all.sh >> /var/log/ansible/run_all_cron.log 2>&1'
|
|
minute: "{{ update_cron_interval.minute }}"
|
|
hour: "{{ update_cron_interval.hour }}"
|
|
day: "{{ update_cron_interval.day }}"
|
|
month: "{{ update_cron_interval.month }}"
|
|
weekday: "{{ update_cron_interval.weekday }}"
|
|
|
|
- name: Setup log rotation
|
|
include_role:
|
|
name: logrotate
|
|
vars:
|
|
logrotate_file_name: /var/log/ansible/run_all_cron.log |