ansible/playbooks/destroy_cloud_inst.yml
2016-08-08 19:36:31 +00:00

25 lines
740 B
YAML

#DIE DIE DIE
# there is no way this could work so fail
#
# only works with -e target=
# requires --extra-vars="target=hostspec"
- name: destroy the cloud instance
hosts: "{{ target }}"
user: root
gather_facts: false
tasks:
- name: fail if the host/ip is not up
local_action: wait_for host={{ inventory_hostname }} port=22 delay=0 timeout=10
when: inventory_hostname not in result.list_vms
- name: pause for 30s before doing it
pause: seconds=30 prompt="Destroying vm now {{ target }}, abort if this is wrong"
- name: find the instance id from the builder
command: curl -s http://169.254.169.254/latest/meta-data/instance-id
register: instanceid
- name: destroy the vm
command: /usr/sbin/halt -p