add destroy_cloud_inst for use against our private cloud
This commit is contained in:
parent
99a8821749
commit
e328deb07f
1 changed files with 24 additions and 0 deletions
24
playbooks/destroy_cloud_inst.yml
Normal file
24
playbooks/destroy_cloud_inst.yml
Normal 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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue