add destroy_cloud_inst for use against our private cloud

This commit is contained in:
Seth Vidal 2013-05-06 19:44:56 +00:00
parent 99a8821749
commit e328deb07f

View file

@ -0,0 +1,24 @@
# 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_string: ${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
action: command curl -s http://169.254.169.254/latest/meta-data/instance-id
register: instanceid
- name: destroy the vm
action: command /usr/sbin/halt -p