From: Deepak C Shetty Date: Thu, 24 Mar 2016 11:28:01 +0000 (+0000) Subject: purge-cluster: Add support for user prompt X-Git-Tag: v1.0.3~10^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F647%2Fhead;p=ceph-ansible.git purge-cluster: Add support for user prompt 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 --- diff --git a/purge-cluster.yml b/purge-cluster.yml index 02913f2d3..14f272e2c 100644 --- a/purge-cluster.yml +++ b/purge-cluster.yml @@ -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: