|
39 | 39 | dest: "{{ icingaweb2_config_dir }}/{{ item }}.ini" |
40 | 40 | owner: "{{ icingaweb2_httpd_user }}" |
41 | 41 | group: "{{ icingaweb2_group }}" |
42 | | - mode: "0770" |
| 42 | + mode: "0660" |
43 | 43 | loop: |
44 | 44 | - config |
45 | 45 | - authentication |
46 | 46 | - groups |
47 | 47 | vars: |
48 | 48 | _i2_config_hash: "{{ lookup('ansible.builtin.vars', 'icingaweb2_' + item) }}" |
49 | 49 |
|
50 | | -- name: Prepare config hash |
| 50 | +- name: Create temporary config variable |
51 | 51 | ansible.builtin.set_fact: |
52 | | - _i2_config_hash: |
| 52 | + _tmp_i2_config_hash: |
| 53 | + roles: {} |
| 54 | + resources: {} |
| 55 | + |
| 56 | +- name: Prepare config hash |
| 57 | + when: icingaweb2_db is defined |
| 58 | + vars: |
| 59 | + _resources: |
53 | 60 | icingaweb2_db: |
54 | 61 | type: db |
55 | 62 | db: "{{ icingaweb2_db['type'] | default('mysql') }}" |
|
65 | 72 | ssl_ca: "{{ icingaweb2_db['ssl_ca'] | default(omit) }}" |
66 | 73 | ssl_cipher: "{{ icingaweb2_db['ssl_cipher'] | default(omit) }}" |
67 | 74 | ssl_capath: "{{ icingaweb2_db['ssl_capath'] | default(omit) }}" |
68 | | - when: icingaweb2_db is defined |
69 | | - |
70 | | -- name: Assemble resources.ini |
71 | | - when: icingaweb2_db is defined or icingaweb2_resources is defined |
72 | | - block: |
73 | | - - name: Manage icingaweb_db resource config |
74 | | - ansible.builtin.template: |
75 | | - src: modules_config.ini.j2 |
76 | | - dest: "{{ icingaweb2_fragments_path }}/resources/resources_01" |
77 | | - owner: root |
78 | | - group: "{{ icingaweb2_group }}" |
79 | | - when: icingaweb2_db is defined |
80 | | - |
81 | | - - name: Set resources facts |
82 | | - ansible.builtin.set_fact: |
83 | | - _i2_config_hash: "{{ icingaweb2_resources }}" |
84 | | - when: icingaweb2_resources is defined |
| 75 | + ansible.builtin.set_fact: |
| 76 | + _tmp_i2_config_hash: "{{ _tmp_i2_config_hash | combine({'resources': _resources}, recursive=true) }}" |
85 | 77 |
|
86 | | - - name: Manage Resources |
87 | | - ansible.builtin.template: |
88 | | - src: modules_config.ini.j2 |
89 | | - dest: "{{ icingaweb2_fragments_path }}/resources/resources_02" |
90 | | - owner: root |
91 | | - group: "{{ icingaweb2_group }}" |
92 | | - when: icingaweb2_resources is defined |
| 78 | +- name: Set resources facts |
| 79 | + when: icingaweb2_resources is defined |
| 80 | + ansible.builtin.set_fact: |
| 81 | + _tmp_i2_config_hash: "{{ _tmp_i2_config_hash | combine({'resources': icingaweb2_resources}, recursive=true) }}" |
93 | 82 |
|
94 | | -- name: Assemble roles.ini |
| 83 | +- name: Assemble roles.ini (adding default admin role) |
95 | 84 | when: icingaweb2_admin_username is defined and icingaweb2_admin_password is defined |
96 | | - block: |
97 | | - - name: Build variable |
98 | | - ansible.builtin.set_fact: |
99 | | - _i2_config_hash: |
100 | | - default_admins: |
101 | | - users: |
102 | | - - "{{ icingaweb2_admin_username }}" |
103 | | - permissions: |
104 | | - - "*" |
105 | | - |
106 | | - - name: Manage icingaweb2_admin privileges |
107 | | - ansible.builtin.template: |
108 | | - src: modules_config.ini.j2 |
109 | | - dest: "{{ icingaweb2_fragments_path }}/roles/roles_01" |
110 | | - owner: root |
111 | | - group: "{{ icingaweb2_group }}" |
112 | | - when: icingaweb2_admin_username is defined and icingaweb2_admin_password is defined |
113 | | - |
114 | | - - name: Build variable |
115 | | - ansible.builtin.set_fact: |
116 | | - _i2_config_hash: "{{ icingaweb2_roles }}" |
117 | | - when: icingaweb2_roles is defined |
118 | | - |
119 | | - - name: Manage icingaweb2_admin privileges |
120 | | - ansible.builtin.template: |
121 | | - src: modules_config.ini.j2 |
122 | | - dest: "{{ icingaweb2_fragments_path }}/roles/roles_02" |
123 | | - owner: root |
124 | | - group: "{{ icingaweb2_group }}" |
125 | | - when: icingaweb2_roles is defined |
| 85 | + vars: |
| 86 | + _tmp_i2_config_hash_admin_role: |
| 87 | + default_admins: |
| 88 | + users: |
| 89 | + - "{{ icingaweb2_admin_username }}" |
| 90 | + permissions: |
| 91 | + - "*" |
| 92 | + ansible.builtin.set_fact: |
| 93 | + _tmp_i2_config_hash: "{{ _tmp_i2_config_hash | combine({'roles': _tmp_i2_config_hash_admin_role}, recursive=true) }}" |
126 | 94 |
|
| 95 | +- name: Assemble roles.ini (adding icingaweb2_roles) |
| 96 | + when: icingaweb2_roles is defined |
| 97 | + ansible.builtin.set_fact: |
| 98 | + _tmp_i2_config_hash: "{{ _tmp_i2_config_hash | combine({'roles': icingaweb2_roles}, recursive=true) }}" |
127 | 99 |
|
128 | | -- name: Assemble configuration files |
129 | | - ansible.builtin.assemble: |
130 | | - dest: "{{ icingaweb2_config_dir }}/{{ item }}.ini" |
131 | | - src: "{{ icingaweb2_fragments_path }}/{{ item }}" |
| 100 | +- name: Deploy configuration files |
| 101 | + loop: "{{ _tmp_i2_config_hash | dict2items }}" |
| 102 | + vars: |
| 103 | + _i2_config_hash: "{{ _tmp_i2_config_hash[item.key] }}" |
| 104 | + ansible.builtin.template: |
| 105 | + src: modules_config.ini.j2 |
| 106 | + dest: "{{ icingaweb2_config_dir }}/{{ item.key }}.ini" |
132 | 107 | group: "{{ icingaweb2_group }}" |
133 | 108 | owner: "{{ icingaweb2_httpd_user }}" |
134 | | - mode: 0770 |
135 | | - loop: |
136 | | - - resources |
137 | | - - roles |
138 | | - |
139 | | - |
140 | | -# {{ icingaweb2_db | ansible.builtin.combine(icingaweb2_db, append_rp)}} |
| 109 | + mode: "0660" |
0 commit comments