CORD-2522 Delete VMs in ERROR state

Change-Id: I3befe68f1e8b896225d7dc67159c5c5fa1338bb8
diff --git a/roles/test-mcord-base/tasks/main.yml b/roles/test-mcord-base/tasks/main.yml
index 193c4d7..470482a 100644
--- a/roles/test-mcord-base/tasks/main.yml
+++ b/roles/test-mcord-base/tasks/main.yml
@@ -19,7 +19,9 @@
 # Run tests to check that the base elements of M-CORD are present
 
 - name: Wait for networks to be synchronized
-  shell: bash -c "source /opt/cord_profile/admin-openrc.sh; neutron net-list|grep '{{ item }}' > /dev/null"
+  shell: source /opt/cord_profile/admin-openrc.sh; neutron net-list|grep '{{ item }}' > /dev/null
+  args:
+    executable: /bin/bash
   register: result
   until: result | success
   retries: 10
@@ -28,8 +30,29 @@
   tags:
     - skip_ansible_lint # running a sub job
 
+- name: Wait for VMs to appear in Nova
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}' > /dev/null
+  args:
+    executable: /bin/bash
+  register: result
+  until: result | success
+  retries: 10
+  delay: 60
+  with_items: "{{ test_services }}"
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Delete any VMs that are in ERROR state (XOS will re-create them)
+  shell: source /opt/cord_profile/admin-openrc.sh; for vm in $(nova list --all-tenants|grep 'ERROR'|awk '{ print $2 }'); do nova delete $vm; done
+  args:
+    executable: /bin/bash
+  tags:
+    - skip_ansible_lint # running a sub job
+
 - name: Wait for VMs to come up
-  shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}.*ACTIVE' > /dev/null"
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item }}.*ACTIVE' > /dev/null
+  args:
+    executable: /bin/bash
   register: result
   until: result | success
   retries: 10
@@ -39,7 +62,9 @@
     - skip_ansible_lint # running a sub job
 
 - name: Verify that VMs are properly networked
-  shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item.vm }}.*ACTIVE.*{{ item.network }}' > /dev/null"
+  shell: source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep '{{ item.vm }}.*ACTIVE.*{{ item.network }}' > /dev/null
+  args:
+    executable: /bin/bash
   with_items: "{{ test_ports }}"
   tags:
     - skip_ansible_lint # running a sub job