Ensure logrotate is installed and enabled
This commit is contained in:
46
tasks/main.yml
Normal file
46
tasks/main.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
# tasks file for ensure_log_rotation
|
||||
- name: 'include variables'
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
include_vars:
|
||||
file: '{{ lookup("first_found", findme ) }}'
|
||||
name: 'ensure_log_rotation'
|
||||
vars:
|
||||
findme:
|
||||
files:
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}-default.yml'
|
||||
- '{{ ansible_distribution }}-default.yml'
|
||||
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}.yml'
|
||||
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}-default.yml'
|
||||
- '{{ ansible_os_family }}-default.yml'
|
||||
- 'default.yml'
|
||||
paths:
|
||||
- '../vars/'
|
||||
errors: 'ignore'
|
||||
- name: 'package discovery'
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- packages is not defined
|
||||
package_facts:
|
||||
- name: 'ensure services'
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- ensure_log_rotation is defined
|
||||
- ensure_log_rotation.package_list is defined
|
||||
- ensure_log_rotation.package_list is iterable
|
||||
- services[item.name] is defined
|
||||
service:
|
||||
enabled: '{{ item.enabled }}'
|
||||
name: '{{ item.name }}'
|
||||
state: '{{ item.state }}'
|
||||
loop: '{{ ensure_log_rotation.service_list }}'
|
||||
loop_control:
|
||||
label: '{{ item.name }} will be {{ item.state }}'
|
||||
notify:
|
||||
- 'ensure_log_rotation.package_facts'
|
||||
- 'ensure_log_rotation.service_facts'
|
||||
- name: 'flush handlers'
|
||||
meta: 'flush_handlers'
|
||||
|
Reference in New Issue
Block a user