Fix waiting OC VMs after restored from snapshot

The libvirt snapshot manipulates with overcloud_nodes, but
waits for the all members of the subnodes group. In general,
those may be unequal. Fix that mismatch.

Change-Id: I92a25daf78f7dfd91cb98618b0ba537ef46828c9
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
Bogdan Dobrelya 2019-09-04 13:57:20 +02:00
parent ad955589c8
commit ea6e6dbcb3
1 changed files with 12 additions and 3 deletions

View File

@ -8,12 +8,21 @@
uri: "{{ libvirt_uri }}"
with_items: "{{ overcloud_nodes }}"
- name: Evaluate overcloud VM libvirt names
set_fact:
libvirt_oc_names: >-
{%- set names=[] -%}
{%- for n in overcloud_nodes -%}
{%- if names.append(hostvars[n['name']]['inventory_hostname']) -%}{%- endif -%}
{%- endfor -%}
{{ names | join('|') }}
- name: Wait for vms to shutdown
async: 300
poll: 0
shell: |
while true
do virsh list | grep subnode > /dev/null || break
do virsh list | grep -E '{{ libvirt_oc_names }}' > /dev/null || break
done
register: vms_shutdown
@ -59,7 +68,7 @@
- name: "Wait for the vms to start"
wait_for:
host: "{{ hostvars[item]['ansible_host'] }}"
host: "{{ hostvars[item.name]['ansible_host'] }}"
port: 22
state: started
with_items: "{{ groups['subnodes'] }}"
with_items: "{{ overcloud_nodes }}"