]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
purge-cluster: Add support for user prompt 647/head
authorDeepak C Shetty <deepakcs@redhat.com>
Thu, 24 Mar 2016 11:28:01 +0000 (11:28 +0000)
committerDeepak C Shetty <deepakcs@redhat.com>
Fri, 25 Mar 2016 04:41:34 +0000 (04:41 +0000)
Add support for user prompt before purging the cluster. This
ensure that accidental invocation of purge-cluster won't
purge the cluster. Defaults to no purging, unless user either
says 'yes' on the prompt or invokes the playbook with:
`-e ireallymeanit=yes`. This also aligns neatly with ceph cli's
--yes-i-really-mean-it option

Signed-off-by: Deepak C Shetty <deepakcs@redhat.com>
purge-cluster.yml

index 02913f2d3b40ae2bcab395873222bded570026ef..14f272e2c09c9ba3de55efef099860dd7675e91a 100644 (file)
@@ -1,6 +1,34 @@
 ---
 # This playbook purges Ceph
 # It removes: packages, configuration files and ALL THE DATA
+#
+# Use it like this:
+# ansible-playbook purge-cluster.yml
+#     Prompts for confirmation to purge, defaults to no and
+#     doesn't purge the cluster. yes purges the cluster.
+#
+# ansible-playbook -e ireallymeanit=yes|no purge-cluster.yml
+#     Overrides the prompt using -e option. Can be used in
+#     automation scripts to avoid interactive prompt.
+
+- name: confirm whether user really meant to purge the cluster
+  hosts: localhost
+
+  vars_prompt:
+    - name: ireallymeanit
+      prompt: Are you sure you want to purge the cluster?
+      default: 'no'
+      private: no
+
+  tasks:
+  - name: exit playbook, if user didn't mean to purge cluster
+    fail:
+      msg: >
+        "Exiting purge-cluster playbook, cluster was NOT purged.
+         To purge the cluster, either say 'yes' on the prompt or
+         or use `-e ireallymeanit=yes` on the command line when
+         invoking the playbook"
+    when: ireallymeanit != 'yes'
 
 - name: stop ceph cluster
   hosts: