Skip to content

Commit 26ca68d

Browse files
committed
Avoid leftover files in Icinga2 configuration deployment
1 parent d68e68b commit 26ca68d

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- "Empty config directories are now cleaned up **after** config assembly within the :code:`icinga2` role. This should avoid leftover files from previous deployments."

roles/icinga2/tasks/configure.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,6 @@
104104
state: absent
105105
dest: "{{ item }}"
106106

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-
131107
- name: collect config files
132108
find:
133109
path: "{{ icinga2_fragments_path }}"
@@ -158,3 +134,27 @@
158134
loop_control:
159135
label: "{{ item.name }}"
160136
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

Comments
 (0)