๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-playbooks/roles/logrotate/tasks/main.yml

47 lines
1.1 KiB

2 years ago
- name: set logrotate_cfg
set_fact:
logrotate_cfg: "{{ logrotate_default_config | d({}) | combine(logrotate_config | d({}), recursive=true) }}"
- name: install logrotate package
include_tasks: tasks/install_packages.yml
vars:
package:
- logrotate
- name: change logrotate config path
replace:
path: /etc/periodic/daily/logrotate
regexp: '\s/etc/logrotate.conf'
replace: ' {{ logrotate_conf_file }}'
when: ansible_distribution == 'Alpine'
- name: edit string in systemd init file
lineinfile:
path: /lib/systemd/system/logrotate.service
regexp: '(ExecStart=/usr/sbin/logrotate )(\S*)(\s*)'
line: '\1{{ logrotate_conf_file }}\3'
backrefs: yes
notify: reload systemd daemons
when: ansible_distribution == 'Debian'
- name: template logrotate config
template:
src: logrotate.j2
dest: "{{ logrotate_conf_file }}"
force: yes
mode: 0644
- name: template logrotate service configs
template:
src: "{{ item.template | d(item.name) }}.j2"
dest: "{{ logrotate_conf_dir ~ '/' ~ item.name }}"
force: yes
mode: 0644
loop: "{{ logrotate_services | d([]) }}"
when: item.name is defined