1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
---
- name: Run kolla-ansible prechecks
ansible.builtin.shell:
cmd: >
. {{ kolla_ansible_venv_path }}/bin/activate &&
kolla-ansible prechecks
--use-test-images
-i /etc/kolla/inventory
-vvv
>/tmp/logs/ansible/reconfigure-prechecks 2>&1
changed_when: false
- name: Remove OVN DB containers and volumes on primary to test recreation (docker)
become: true
when:
- scenario == 'ovn'
- container_engine == 'docker'
vars:
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
block:
- name: Remove OVN DB containers
community.docker.docker_container:
name: "{{ item }}"
state: absent
loop: "{{ ovn_db_services }}"
- name: Remove OVN DB volumes
community.docker.docker_volume:
name: "{{ item }}"
state: absent
loop: "{{ ovn_db_services }}"
- name: "Capture state of containers prior to reconfigure (docker)"
become: true
vars:
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
when:
- container_engine == 'docker'
block:
- name: List docker containers
community.docker.docker_host_info:
containers: true
register: _docker_host_info
- name: Get details of all containers on host
community.docker.docker_container_info:
name: "{{ item }}"
loop: "{{ _docker_host_info.containers | map(attribute='Names') | map('first') | map('regex_replace', '^/', '') | list }}"
register: _deploy_docker_info
- name: Build container timestamps dict post-deploy
ansible.builtin.set_fact:
_deploy_docker_container_times: >-
{{
_deploy_docker_container_times | default({}) |
combine({
item.item: {
'started_at': item.container.State.StartedAt,
'finished_at': item.container.State.FinishedAt
}
})
}}
loop: "{{ _deploy_docker_info.results }}"
when:
- item.exists
- item.item not in ovn_db_services
- name: Remove OVN DB containers and volumes on primary to test recreation (podman)
become: true
when:
- scenario == 'ovn'
- container_engine == 'podman'
vars:
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
block:
- name: Remove OVN DB containers
containers.podman.podman_container:
name: "{{ item }}"
state: absent
loop: "{{ ovn_db_services }}"
- name: Remove OVN DB volumes
containers.podman.podman_volume:
name: "{{ item }}"
state: absent
loop: "{{ ovn_db_services }}"
- name: "Capture state of containers prior to reconfigure (podman)"
become: true
vars:
# NOTE(blanson): There is a bug in podman 4.3.1 (debian-bookworm version)
# which prevents nova_compute from being idempotent.
# this isn't a big issues, but we can't just install a newer podman version.
# https://github.com/containers/podman/issues/17189
ignored_services: >-
{{ ovn_db_services
+ (['nova_compute']
if ansible_facts.distribution | lower == 'debian'
and ansible_facts.distribution_major_version | int == 12
else []) }}
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
when:
- container_engine == 'podman'
block:
- name: "Get podman containers info post-deploy"
containers.podman.podman_container_info:
register: _deploy_podman_facts
- name: "Build podman container timestamps dict post-deploy"
ansible.builtin.set_fact:
_deploy_podman_container_times: >-
{{
_deploy_podman_container_times | default({}) |
combine({
item.Name: {
'started_at': item.State.StartedAt,
'finished_at': item.State.FinishedAt
}
})
}}
loop: "{{ _deploy_podman_facts.containers }}"
when: item.Name not in ignored_services
- name: Run kolla-ansible reconfigure
ansible.builtin.shell:
cmd: >
. {{ kolla_ansible_venv_path }}/bin/activate &&
kolla-ansible reconfigure
-i /etc/kolla/inventory
-vvv
>/tmp/logs/ansible/reconfigure 2>&1
changed_when: true
- name: "Capture state of containers post reconfigure (docker)"
become: true
vars:
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
when:
- container_engine == 'docker'
block:
- name: List docker containers
community.docker.docker_host_info:
containers: true
register: _docker_host_info
changed_when: false
- name: Get details of all containers on host
community.docker.docker_container_info:
name: "{{ item }}"
loop: "{{ _docker_host_info.containers | map(attribute='Names') | map('first') | map('regex_replace', '^/', '') | list }}"
register: _reconfigure_docker_info
- name: Build container timestamps dict post-reconfigure
ansible.builtin.set_fact:
_reconfigure_docker_container_times: >-
{{
_reconfigure_docker_container_times | default({}) |
combine({
item.item: {
'started_at': item.container.State.StartedAt,
'finished_at': item.container.State.FinishedAt
}
})
}}
loop: "{{ _reconfigure_docker_info.results }}"
when:
- item.exists
- item.item not in ovn_db_services
- name: "Capture state of containers post reconfigure (podman)"
become: true
vars:
# NOTE(blanson): There is a bug in podman 4.3.1 (debian-bookworm version)
# which prevents nova_compute from being idempotent.
# this isn't a big issues, but we can't just install a newer podman version.
# https://github.com/containers/podman/issues/17189
ignored_services: >-
{{ ovn_db_services
+ (['nova_compute']
if ansible_facts.distribution | lower == 'debian'
and ansible_facts.distribution_major_version | int == 12
else []) }}
ovn_db_services:
- "ovn_nb_db"
- "ovn_sb_db"
when:
- container_engine == 'podman'
block:
- name: "Get podman containers info post-reconfigure"
containers.podman.podman_container_info:
register: _reconfigure_podman_facts
- name: "Build podman container timestamps dict post-reconfigure"
ansible.builtin.set_fact:
_reconfigure_podman_container_times: >-
{{
_reconfigure_podman_container_times | default({}) |
combine({
item.Name: {
'started_at': item.State.StartedAt,
'finished_at': item.State.FinishedAt
}
})
}}
loop: "{{ _reconfigure_podman_facts.containers }}"
when: item.Name not in ignored_services
- name: Assert that containers were not restarted during reconfigure (docker)
ansible.builtin.assert:
that:
- _deploy_docker_container_times == _reconfigure_docker_container_times
fail_msg: |-
Some containers were restarted or replaced during reconfigure:
{% for name in _deploy_docker_container_times %}
{% if _deploy_docker_container_times[name] != _reconfigure_docker_container_times.get(name, {}) %}
- {{ name }}:
initial_start_time: {{ _deploy_docker_container_times[name].started_at }}
reconfigure_start_time: {{ _reconfigure_docker_container_times.get(name, {}).get('started_at', 'MISSING') }}
{% endif %}
{% endfor %}
success_msg: "All containers stayed the same after reconfigure."
when:
- container_engine == 'docker'
- name: Assert that containers were not restarted during reconfigure (podman)
ansible.builtin.assert:
that:
- _deploy_podman_container_times == _reconfigure_podman_container_times
fail_msg: |-
Some containers were restarted or replaced during reconfigure:
{% for name in _deploy_podman_container_times %}
{% if _deploy_podman_container_times[name] != _reconfigure_podman_container_times.get(name, {}) %}
- {{ name }}:
initial_start_time: {{ _deploy_podman_container_times[name].started_at }}
reconfigure_start_time: {{ _reconfigure_podman_container_times.get(name, {}).get('started_at', 'MISSING') }}
{% endif %}
{% endfor %}
success_msg: "All containers stayed the same after reconfigure."
when:
- container_engine == 'podman'
|