terminate.yml 895 B

12345678910111213141516171819202122
  1. - name: Terminate instance(s)
  2. hosts: localhost
  3. connection: local
  4. gather_facts: no
  5. vars_files:
  6. - vars.yml
  7. tasks:
  8. - name: Delete the OpenStack Stack
  9. command: 'heat stack-delete openshift-ansible-{{ cluster_id }}-stack'
  10. register: stack_delete_result
  11. changed_when: stack_delete_result.rc == 0
  12. failed_when: stack_delete_result.rc != 0 and 'could not be found' not in stack_delete_result.stdout
  13. - name: Wait for the completion of the OpenStack Stack deletion
  14. shell: 'heat stack-show openshift-ansible-{{ cluster_id }}-stack | awk ''$2 == "stack_status" {print $4}'''
  15. when: stack_delete_result.changed
  16. register: stack_show_result
  17. until: stack_show_result.stdout != 'DELETE_IN_PROGRESS'
  18. retries: 60
  19. delay: 1
  20. failed_when: '"Stack not found" not in stack_show_result.stderr and
  21. stack_show_result.stdout != "DELETE_COMPLETE"'