---
|
|
- hosts: vm_hosts
|
|
vars_prompt:
|
|
- name: container_name
|
|
prompt: 'what container should be destroyed?'
|
|
private: no
|
|
- name: confirm1
|
|
prompt: 'are you sure you want to delete the container (NO/yes)?'
|
|
private: no
|
|
- name: confirm2
|
|
prompt: 'if you really are sure, enter the container name again'
|
|
private: no
|
|
tasks:
|
|
- fail:
|
|
msg: "Task aborted by the user."
|
|
when: "confirm1 != 'yes' or confirm2 != '{{ container_name }}'"
|
|
- block:
|
|
- name: shutdown lxc container
|
|
lxc_container:
|
|
name: "{{ container_name }}"
|
|
state: stopped
|
|
- name: clean LVM volume
|
|
command: "dd if=/dev/zero of=/dev/{{ inventory_hostname }}vg/vm_{{ container_name }} bs=1M count=128"
|
|
- name: delete lxc container
|
|
lxc_container:
|
|
name: "{{ container_name }}"
|
|
state: absent
|
|
when: "confirm1 == 'yes' and confirm2 == '{{ container_name }}'"
|