3eceba5749
This converts the reprepro configuration from our existing puppet to Ansible. This takes a more direct approach; the templating done by the puppet version started simple but over the years grew several different options to handle various use-cases. This means you not only had to understand the rather obscure reprepro configuration, but then *also* figure out how to translate that from our puppet template layers. Here the configuration files are kept directly (they were copied from the existing mirror-update.openstack.org) and deployed with some light wrapper tasks in reprepro/tasks/utils which avoids most duplication. Note the initial cron jobs are left disabled so we can run some manual testing before letting it go automatically. Change-Id: I96a9ff1efbf51c4164621028b7a3a1e2e1077d5c
30 lines
1006 B
YAML
30 lines
1006 B
YAML
- name: Check for filename
|
|
fail:
|
|
msg: Must set logrotate_file_name for logfile to rotate
|
|
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.
|
|
# "/var/log/ansible/ansible.log" becomes "ansible.log.37237.conf" for example
|
|
- name: Create a unique config name
|
|
set_fact:
|
|
logrotate_generated_config_file_name: "{{ logrotate_file_name | basename }}.{{ (logrotate_file_name|hash('sha1'))[0:5] }}.conf"
|
|
|
|
- name: 'Install {{ logrotate_file_name }} rotatation config file'
|
|
template:
|
|
src: logrotate.conf.j2
|
|
dest: '/etc/logrotate.d/{{ logrotate_config_file_name|default(logrotate_generated_config_file_name) }}'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|