From ea6e6dbcb3ddc6765583658aa5a2b1967973f91f Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Wed, 4 Sep 2019 13:57:20 +0200 Subject: [PATCH] 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 --- roles/snapshot-libvirt/tasks/main.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/roles/snapshot-libvirt/tasks/main.yml b/roles/snapshot-libvirt/tasks/main.yml index fe59a4a8c..a09f2df42 100644 --- a/roles/snapshot-libvirt/tasks/main.yml +++ b/roles/snapshot-libvirt/tasks/main.yml @@ -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 }}"