From d2a2b720c929bca5f3eb0870e9652779746c9b65 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 25 Jul 2016 16:38:57 +0100 Subject: [PATCH] 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 --- playbooks/lxc-containers-destroy.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/playbooks/lxc-containers-destroy.yml b/playbooks/lxc-containers-destroy.yml index bbf3b885fe..2a40e4267e 100644 --- a/playbooks/lxc-containers-destroy.yml +++ b/playbooks/lxc-containers-destroy.yml @@ -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