From b11e54e88bd0bf9961a157d0aa3256fb4ea0aab4 Mon Sep 17 00:00:00 2001 From: Jason Rothstein Date: Sun, 25 Jul 2021 04:11:20 +0000 Subject: [PATCH] Really only remove one set of flush handlers... --- tasks/main.yml | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index d658064..405a990 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1 +1,90 @@ +--- +# 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 + ansible.builtin.package_facts: +- name: 'service discovery' + when: + - ansible_system == 'Linux' + - services is not defined + ansible.builtin.service_facts: +- name: 'ensure packages' + when: + - ansible_system == 'Linux' + - ensure_log_rotation is defined + - ensure_log_rotation.package_list is defined + - ensure_log_rotation.package_list is iterable + - packages[item.name] is not defined + ansible.builtin.package: + name: '{{ item.name }}' + state: '{{ item.state }}' + loop: '{{ ensure_log_rotation.package_list }}' + loop_control: + label: '{{ item.name }} will be {{ item.state }}' + notify: + - 'ensure_log_rotation.package_facts' + - 'ensure_log_rotation.service_facts' +- name: 'ensure configuration' + when: + - ansible_system == 'Linux' + - ensure_log_rotation is defined + - ensure_log_rotation.template_list is defined + - ensure_log_rotation.template_list is iterable + ansible.builtin.template: + attributes: '{{ item.attributes | default(omit) }}' + backup: '{{ item.backup | default(omit) }}' + dest: '{{ item.dest }}' + follow: '{{ item.follow | default(omit) }}' + force: '{{ item.force | default(omit) }}' + group: '{{ item.group | default(omit) }}' + mode: '{{ item.mode | default(omit) }}' + owner: '{{ item.owner | default(omit) }}' + selevel: '{{ item.selevel | default(omit) }}' + serole: '{{ item.serole | default(omit) }}' + setype: '{{ item.setype | default(omit) }}' + seuser: '{{ item.seuser | default(omit) }}' + src: '{{ item.src | default(omit) }}' + validate: '{{ item.validate | default(omit) }}' + loop: '{{ ensure_log_rotation.template_list }}' + loop_control: + label: '{{ item.dest }}' +- name: 'ensure services' + when: + - ansible_system == 'Linux' + - ensure_log_rotation is defined + - ensure_log_rotation.service_list is defined + - ensure_log_rotation.service_list is iterable + ansible.builtin.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' +