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 <deepakcs@redhat.com>
pull/647/head
Deepak C Shetty 2016-03-24 11:28:01 +00:00
parent f5b6290a08
commit 2d12cc52c3
1 changed files with 28 additions and 0 deletions

View 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: