|
104 | 104 | state: absent |
105 | 105 | dest: "{{ item }}" |
106 | 106 |
|
107 | | -- name: Remove empty config dirs (icinga2_config_path) # noqa: command-instead-of-shell |
108 | | - when: icinga2_config_directories is defined |
109 | | - vars: |
110 | | - _icinga2_config_directories: "{{ |
111 | | - ( |
112 | | - (icinga2_config_directories | select('match', '^conf.d/.*')) + |
113 | | - (icinga2_config_directories | select('match', '^zones.d/.*')) + |
114 | | - ((icinga2_config_directories | select('match', '^' + [icinga2_confd, '.*'] | path_join)) if icinga2_confd is string else []) |
115 | | - ) | netways.icinga.prefix(prefix=icinga2_config_path + '/') | join(' ') |
116 | | - }}" |
117 | | - ansible.builtin.shell: |
118 | | - cmd: | |
119 | | - for path in {{ _icinga2_config_directories }} |
120 | | - do |
121 | | - if [ -d "$path" ]; then |
122 | | - find "$path" -mindepth 1 -type d -empty -print -exec rmdir {} + |
123 | | - fi |
124 | | - done |
125 | | - register: _removed_dirs |
126 | | - until: _removed_dirs.stdout_lines | length == 0 |
127 | | - retries: 100 |
128 | | - delay: 0 |
129 | | - changed_when: _removed_dirs.attempts > 1 |
130 | | - |
131 | 107 | - name: collect config files |
132 | 108 | find: |
133 | 109 | path: "{{ icinga2_fragments_path }}" |
|
158 | 134 | loop_control: |
159 | 135 | label: "{{ item.name }}" |
160 | 136 | notify: check-and-reload-icinga2-service |
| 137 | + |
| 138 | +- name: Remove empty config dirs (icinga2_config_path) # noqa: command-instead-of-shell |
| 139 | + when: icinga2_config_directories is defined |
| 140 | + vars: |
| 141 | + _icinga2_config_directories: "{{ |
| 142 | + ( |
| 143 | + (icinga2_config_directories | select('match', '^conf.d/.*')) + |
| 144 | + (icinga2_config_directories | select('match', '^zones.d/.*')) + |
| 145 | + ((icinga2_config_directories | select('match', '^' + [icinga2_confd, '.*'] | path_join)) if icinga2_confd is string else []) |
| 146 | + ) | netways.icinga.prefix(prefix=icinga2_config_path + '/') | join(' ') |
| 147 | + }}" |
| 148 | + ansible.builtin.shell: |
| 149 | + cmd: | |
| 150 | + for path in {{ _icinga2_config_directories }} |
| 151 | + do |
| 152 | + if [ -d "$path" ]; then |
| 153 | + find "$path" -mindepth 1 -type d -empty -print -exec rmdir {} + |
| 154 | + fi |
| 155 | + done |
| 156 | + register: _removed_dirs |
| 157 | + until: _removed_dirs.stdout_lines | length == 0 |
| 158 | + retries: 100 |
| 159 | + delay: 0 |
| 160 | + changed_when: _removed_dirs.attempts > 1 |
0 commit comments