Confirm container data destroys

Currently running the lxc-containers-destroy playbook will, when
agreed to, destroy all containers and container data across the
entire deployment.

This patch separates the removal of the container from the removal
of the data and includes a prompt to the user to confirm each
option.

The option can be pre-answered through the use of the boolean
variable 'force_containers_data_destroy'.

Change-Id: I70c4819dbe6fc996dd780f205f3e08c300f18591
This commit is contained in:
Jesse Pretorius 2016-07-25 16:38:57 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 91378741dc
commit d2a2b720c9

View File

@ -28,6 +28,17 @@
tags:
- container-destroy
- name: Destroy container service directories
file:
path: "{{ item }}"
state: "absent"
with_items:
- "/var/lib/lxc/{{ container_name }}"
delegate_to: "{{ physical_host }}"
when:
- force_containers_destroy | bool
tags:
- container-directories-service
- name: Destroy container data directories
file:
path: "{{ item }}"
state: "absent"
@ -35,15 +46,20 @@
- "/openstack/{{ container_name }}"
- "/openstack/backup/{{ container_name }}"
- "/openstack/log/{{ container_name }}"
- "/var/lib/lxc/{{ container_name }}"
- "{{ lxc_container_directory|default('/var/lib/lxc') }}/{{ container_name }}"
delegate_to: "{{ physical_host }}"
when: force_containers_destroy | bool
when:
- force_containers_destroy | bool
- force_containers_data_destroy | bool
tags:
- container-directories
- container-directories-data
vars_prompt:
- name: "force_containers_destroy"
prompt: "Are you sure you want to destroy LXC containers?"
prompt: "Are you sure you want to destroy the LXC containers?"
default: "no"
private: no
when: force_containers_destroy is undefined
- name: "force_containers_data_destroy"
prompt: "Are you sure you want to destroy the LXC container data?"
default: "no"
private: no
when: force_containers_data_destroy is undefined