From 2d12cc52c3209b4ab4fa0c73392888c1a0598251 Mon Sep 17 00:00:00 2001 From: Deepak C Shetty Date: Thu, 24 Mar 2016 11:28:01 +0000 Subject: [PATCH] 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 --- purge-cluster.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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: -- 2.47.3