re-add mistakenly deleted destroy_virt_inst playbook
Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
parent
b9eed95b04
commit
c056492059
1 changed files with 45 additions and 0 deletions
45
playbooks/destroy_virt_inst.yml
Normal file
45
playbooks/destroy_virt_inst.yml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# only works with -e target=
|
||||||
|
# read configs from host_vars
|
||||||
|
# check for host already existing
|
||||||
|
# if it exists
|
||||||
|
# kill it
|
||||||
|
# lvremove disk?
|
||||||
|
# if not
|
||||||
|
# exit with failure
|
||||||
|
|
||||||
|
# requires --extra-vars="target=hostspec"
|
||||||
|
|
||||||
|
- name: destroy and undefine vm
|
||||||
|
hosts: "{{ target }}"
|
||||||
|
user: root
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: get vm list on the vmhost
|
||||||
|
delegate_to: "{{ vmhost }}"
|
||||||
|
virt: command=list_vms
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: fail if the host is not already defined/existent
|
||||||
|
local_action: fail msg="host does not exist on {{ vmhost }}"
|
||||||
|
when: inventory_hostname not in result.list_vms
|
||||||
|
|
||||||
|
- name: schedule 30m host downtime in nagios
|
||||||
|
nagios: action=downtime minutes=60 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
|
||||||
|
delegate_to: noc01.phx2.fedoraproject.org
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: pause for 30s before doing it
|
||||||
|
pause: seconds=30 prompt="Destroying (and lvremove for) vm now {{ target }}, abort if this is wrong"
|
||||||
|
|
||||||
|
- name: destroy the vm
|
||||||
|
virt: name={{ inventory_hostname }} command=destroy
|
||||||
|
delegate_to: "{{ vmhost }}"
|
||||||
|
|
||||||
|
- name: undefine the vm
|
||||||
|
virt: name={{ inventory_hostname }} command=undefine
|
||||||
|
delegate_to: "{{ vmhost }}"
|
||||||
|
|
||||||
|
- name: destroy the lv
|
||||||
|
command: /sbin/lvremove -f {{volgroup}}/{{inventory_hostname}}
|
||||||
|
delegate_to: "{{ vmhost }}"
|
Loading…
Add table
Add a link
Reference in a new issue