From e328deb07f745cc6096294cb8a77dc6a5d51289c Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Mon, 6 May 2013 19:44:56 +0000 Subject: [PATCH] add destroy_cloud_inst for use against our private cloud --- playbooks/destroy_cloud_inst.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 playbooks/destroy_cloud_inst.yml diff --git a/playbooks/destroy_cloud_inst.yml b/playbooks/destroy_cloud_inst.yml new file mode 100644 index 0000000000..1426904fa0 --- /dev/null +++ b/playbooks/destroy_cloud_inst.yml @@ -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 + +