diff --git a/roles/icinga2_master/tasks/main.yml b/roles/icinga2_master/tasks/main.yml index 714750d..ec32a98 100644 --- a/roles/icinga2_master/tasks/main.yml +++ b/roles/icinga2_master/tasks/main.yml @@ -34,35 +34,18 @@ mode: 0644 notify: Reload icinga2 service -- name: Create master zone directory +- name: Create needed directories become: true ansible.builtin.file: - path: /etc/icinga2/zones.d/master - state: directory - owner: nagios - group: nagios - mode: 0750 - -- name: Copy files under master zone directory - become: true - ansible.builtin.template: - src: "{{ item }}" - dest: "/etc/icinga2/zones.d/master/{{ item | basename | replace('.j2', '') }}" - owner: nagios - group: nagios - mode: 0644 - with_fileglob: - - "{{ role_path }}/templates/zones.d/master/*.conf.j2" - notify: Reload icinga2 service - -- name: Create global-templates zone directory - become: true - ansible.builtin.file: - path: /etc/icinga2/zones.d/global-templates + path: "/etc/icinga2/{{ item }}" state: directory owner: nagios group: nagios mode: 0750 + loop: + - zones.d/global-templates + - zones.d/master + - zones.d/master/services - name: Copy files under global-templates zone directory become: true @@ -76,14 +59,17 @@ - "{{ role_path }}/templates/zones.d/global-templates/*.conf.j2" notify: Reload icinga2 service -- name: Create services directory +- name: Copy files under master zone directory become: true - ansible.builtin.file: - path: /etc/icinga2/zones.d/master/services - state: directory + ansible.builtin.template: + src: "{{ item }}" + dest: "/etc/icinga2/zones.d/master/{{ item | basename | replace('.j2', '') }}" owner: nagios group: nagios - mode: 0750 + mode: 0644 + with_fileglob: + - "{{ role_path }}/templates/zones.d/master/*.conf.j2" + notify: Reload icinga2 service - name: Copy common services become: true