aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/nova/tasks/reconfigure.yml
blob: b551dd92acc1b49685b58ec51a20251aadc8ba07 (plain)
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
---
- name: Ensuring the nova libvirt, ssh, conductor, api, consoleauth and scheduler containers are up
  kolla_docker:
    name: "{{ item.name }}"
    action: "get_container_state"
  register: container_state
  failed_when: container_state.Running == false
  when: inventory_hostname in groups[item.group]
  with_items:
    - { name: nova_libvirt, group: compute }
    - { name: nova_ssh, group: compute }
    - { name: nova_conductor, group: nova-conductor }
    - { name: nova_api, group: nova-api }
    - { name: nova_consoleauth, group: nova-consoleauth }
    - { name: nova_scheduler, group: nova-scheduler }

- name: Ensuring the nova_compute container is up
  kolla_docker:
    name: "nova_compute"
    action: "get_container_state"
  register: container_state
  failed_when: container_state.Running == false
  when:
    - not enable_nova_fake | bool
    - inventory_hostname in groups['compute']

- name: Ensuring the nova_compute_ironic container is up
  kolla_docker:
    name: "nova_compute_ironic"
    action: "get_container_state"
  register: container_state
  failed_when: container_state.Running == false
  when:
    - enable_ironic | bool
    - inventory_hostname in groups['nova-compute-ironic']

- name: Ensuring the nova_novncproxy container is up
  kolla_docker:
    name: "nova_novncproxy"
    action: "get_container_state"
  register: container_state
  failed_when: container_state.Running == false
  when:
    - nova_console == 'novnc'
    - inventory_hostname in groups['nova-novncproxy']

- name: Ensuring the nova_spicehtml5proxy container is up
  kolla_docker:
    name: "nova_spicehtml5proxy"
    action: "get_container_state"
  register: container_state
  failed_when: container_state.Running == false
  when:
    - nova_console == 'spice'
    - inventory_hostname in groups['nova-spicehtml5proxy']

- include: config.yml

- name: Check the configs for nova libvirt, ssh, conductor, api, consoleauth and scheduler containers
  command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
  changed_when: false
  failed_when: false
  register: check_results
  when: inventory_hostname in groups[item.group]
  with_items:
    - { name: nova_libvirt, group: compute }
    - { name: nova_ssh, group: compute }
    - { name: nova_conductor, group: nova-conductor }
    - { name: nova_api, group: nova-api }
    - { name: nova_consoleauth, group: nova-consoleauth }
    - { name: nova_scheduler, group: nova-scheduler }

- name: Check the configs in the nova_compute container
  command: docker exec nova_compute /usr/local/bin/kolla_set_configs --check
  changed_when: false
  failed_when: false
  register: nova_compute_check_result
  when:
    - not enable_nova_fake | bool
    - inventory_hostname in groups['compute']

- name: Check the configs in the nova_compute_ironic container
  command: docker exec nova_compute_ironic /usr/local/bin/kolla_set_configs --check
  changed_when: false
  failed_when: false
  register: nova_compute_ironic_check_result
  when:
    - enable_ironic | bool
    - inventory_hostname in groups['nova-compute-ironic']

- name: Check the configs in the nova_novncproxy container
  command: docker exec nova_novncproxy /usr/local/bin/kolla_set_configs --check
  changed_when: false
  failed_when: false
  register: nova_novncproxy_check_result
  when:
    - nova_console == 'novnc'
    - inventory_hostname in groups['nova-novncproxy']

- name: Check the configs in the nova_spicehtml5proxy container
  command: docker exec nova_spicehtml5proxy /usr/local/bin/kolla_set_configs --check
  changed_when: false
  failed_when: false
  register: nova_spicehtml5proxy_check_result
  when:
    - nova_console == 'spice'
    - inventory_hostname in groups['nova-spicehtml5proxy']

# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
# just remove the container and start again
- name: Containers config strategy for nova libvirt, ssh, conductor, api, consoleauth and scheduler containers
  kolla_docker:
    name: "{{ item.name }}"
    action: "get_container_env"
  register: container_envs
  when: inventory_hostname in groups[item.group]
  with_items:
    - { name: nova_libvirt, group: compute }
    - { name: nova_ssh, group: compute }
    - { name: nova_conductor, group: nova-conductor }
    - { name: nova_api, group: nova-api }
    - { name: nova_consoleauth, group: nova-consoleauth }
    - { name: nova_scheduler, group: nova-scheduler }

- name: Container config strategy for nova_compute
  kolla_docker:
    name: nova_compute
    action: "get_container_env"
  register: nova_compute_container_env
  when:
    - not enable_nova_fake | bool
    - inventory_hostname in groups['compute']

- name: Container config strategy for nova_compute_ironic
  kolla_docker:
    name: nova_compute_ironic
    action: "get_container_env"
  register: nova_compute_ironic_container_env
  when:
    - enable_ironic | bool
    - inventory_hostname in groups['nova-compute-ironic']

- name: Container config strategy for nova_novncproxy
  kolla_docker:
    name: nova_novncproxy
    action: "get_container_env"
  register: nova_novncproxy_container_env
  when:
    - nova_console == 'novnc'
    - inventory_hostname in groups['nova-novncproxy']

- name: Container config strategy for nova_spicehtml5proxy
  kolla_docker:
    name: nova_spicehtml5proxy
    action: "get_container_env"
  register: nova_spicehtml5proxy_container_env
  when:
    - nova_console == 'spice'
    - inventory_hostname in groups['nova-spicehtml5proxy']

- name: Remove the nova libvirt, ssh, conductor, api, consoleauth and scheduler containers
  kolla_docker:
    name: "{{ item[0]['name'] }}"
    action: "remove_container"
  register: remove_containers
  until: remote_container|success
  retries: "{{ item[0]['retries']|default(0) }}"
  when:
    - inventory_hostname in groups[item[0]['group']]
    - config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
    - item[2]['rc'] == 1
  with_together:
    # NOTE(Jeffrey4l): retry 1 to remove nova_libvirt container because when
    # guests running, nova_libvirt will raise error even though it is removed.
    - [{ name: nova_libvirt, group: compute, retries: 1 },
       { name: nova_ssh, group: compute },
       { name: nova_conductor, group: nova-conductor },
       { name: nova_api, group: nova-api },
       { name: nova_consoleauth, group: nova-consoleauth },
       { name: nova_scheduler, group: nova-scheduler }]
    - "{{ container_envs.results }}"
    - "{{ check_results.results }}"

- name: Remove nova_compute container
  kolla_docker:
    name: nova_compute
    action: "remove_container"
  register: remove_nova_compute_container
  when:
    - not enable_nova_fake | bool
    - inventory_hostname in groups['compute']
    - config_strategy == 'COPY_ONCE' or nova_compute_container_env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
    - nova_compute_check_result['rc'] == 1

- name: Remove nova_compute_ironic container
  kolla_docker:
    name: nova_compute_ironic
    action: "remove_container"
  register: remove_nova_compute_ironic_container
  when:
    - enable_ironic | bool
    - inventory_hostname in groups['nova-compute-ironic']
    - config_strategy == 'COPY_ONCE' or nova_compute_ironic_container_env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
    - nova_compute_ironic_check_result['rc'] == 1

- name: Remove nova_novncproxy container
  kolla_docker:
    name: nova_novncproxy
    action: "remove_container"
  register: remove_nova_novncproxy_container
  when:
    - nova_console == 'novnc'
    - inventory_hostname in groups['nova-novncproxy']
    - config_strategy == 'COPY_ONCE' or nova_novncproxy_container_env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
    - nova_novncproxy_check_result['rc'] == 1

- name: Remove nova_spicehtml5proxy container
  kolla_docker:
    name: nova_spicehtml5proxy
    action: "remove_container"
  register: remove_nova_spicehtml5proxy_container
  when:
    - nova_console == 'spice'
    - inventory_hostname in groups['nova-spicehtml5proxy']
    - config_strategy == 'COPY_ONCE' or nova_spicehtml5proxy_container_env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
    - nova_spicehtml5proxy_check_result['rc'] == 1

- include: start.yml
  when: remove_containers.changed

- include: start.yml
  when:
    - not enable_nova_fake | bool
    - remove_nova_compute_container.changed

- include: start.yml
  when:
    - enable_ironic | bool
    - remove_nova_compute_ironic_container.changed

- include: start.yml
  when:
    - enable_ironic | bool
    - remove_nova_compute_ironic_container.changed

- include: start.yml
  when:
    - nova_console == 'novnc'
    - remove_nova_novncproxy_container.changed

- include: start.yml
  when:
    - nova_console == 'spice'
    - remove_nova_spicehtml5proxy_container.changed

- name: Restart the nova libvirt, ssh, conductor, api, consoleauth and scheduler containers
  kolla_docker:
    name: "{{ item[0]['name'] }}"
    action: "restart_container"
  when:
    - config_strategy == 'COPY_ALWAYS'
    - inventory_hostname in groups[item[0]['group']]
    - item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
    - item[2]['rc'] == 1
  with_together:
    - [{ name: nova_libvirt, group: compute },
       { name: nova_ssh, group: compute },
       { name: nova_conductor, group: nova-conductor },
       { name: nova_api, group: nova-api },
       { name: nova_consoleauth, group: nova-consoleauth },
       { name: nova_scheduler, group: nova-scheduler }]
    - "{{ container_envs.results }}"
    - "{{ check_results.results }}"

- name: Restart the nova_compute container
  kolla_docker:
    name: "nova_compute"
    action: "restart_container"
  when:
    - not enable_nova_fake | bool
    - config_strategy == 'COPY_ALWAYS'
    - inventory_hostname in groups['compute']
    - nova_compute_container_env['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
    - nova_compute_check_result['rc'] == 1

- name: Restart the nova_compute_ironic container
  kolla_docker:
    name: "nova_compute_ironic"
    action: "restart_container"
  when:
    - enable_ironic | bool
    - config_strategy == 'COPY_ALWAYS'
    - inventory_hostname in groups['nova-compute-ironic']
    - nova_compute_ironic_container_env['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
    - nova_compute_ironic_check_result['rc'] == 1

- name: Restart the nova_novncproxy container
  kolla_docker:
    name: "nova_novncproxy"
    action: "restart_container"
  when:
    - nova_console == 'novnc'
    - config_strategy == 'COPY_ALWAYS'
    - inventory_hostname in groups['nova-novncproxy']
    - nova_novncproxy_container_env['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
    - nova_novncproxy_check_result['rc'] == 1

- name: Restart the nova_spicehtml5proxy container
  kolla_docker:
    name: "nova_spicehtml5proxy"
    action: "restart_container"
  when:
    - nova_console == 'spice'
    - config_strategy == 'COPY_ALWAYS'
    - inventory_hostname in groups['nova-spicehtml5proxy']
    - nova_spicehtml5proxy_container_env['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
    - nova_spicehtml5proxy_check_result['rc'] == 1