Playbooks to a new Lilik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
1.0 KiB

---
- 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 }}'"