2013-09-30 00:44:46 +02:00
|
|
|
|
Prompts
|
|
|
|
|
=======
|
2012-05-13 17:00:02 +02:00
|
|
|
|
|
2013-10-05 19:50:53 +02:00
|
|
|
|
When running a playbook, you may wish to prompt the user for certain input, and can
|
|
|
|
|
do so with the 'vars_prompt' section.
|
2012-08-01 04:19:04 +02:00
|
|
|
|
|
2013-10-05 19:50:53 +02:00
|
|
|
|
A common use for this might be for asking for sensitive data that you do not want to record.
|
2012-05-13 17:00:02 +02:00
|
|
|
|
|
2013-09-30 00:44:46 +02:00
|
|
|
|
This has uses beyond security, for instance, you may use the same playbook for all
|
2012-05-13 17:00:02 +02:00
|
|
|
|
software releases and would prompt for a particular release version
|
2013-10-05 19:50:53 +02:00
|
|
|
|
in a push-script.
|
|
|
|
|
|
|
|
|
|
Here is a most basic example::
|
2012-05-13 17:00:02 +02:00
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
- hosts: all
|
2013-09-07 23:19:23 +02:00
|
|
|
|
remote_user: root
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2012-05-13 17:00:02 +02:00
|
|
|
|
vars:
|
|
|
|
|
from: "camelot"
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2012-05-13 17:00:02 +02:00
|
|
|
|
vars_prompt:
|
|
|
|
|
name: "what is your name?"
|
|
|
|
|
quest: "what is your quest?"
|
|
|
|
|
favcolor: "what is your favorite color?"
|
|
|
|
|
|
2013-06-18 17:25:51 +02:00
|
|
|
|
If you have a variable that changes infrequently, it might make sense to
|
2013-07-10 21:09:12 +02:00
|
|
|
|
provide a default value that can be overridden. This can be accomplished using
|
2013-06-18 17:25:51 +02:00
|
|
|
|
the default argument::
|
|
|
|
|
|
|
|
|
|
vars_prompt:
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2013-06-18 17:25:51 +02:00
|
|
|
|
- name: "release_version"
|
|
|
|
|
prompt: "Product release version"
|
|
|
|
|
default: "1.0"
|
|
|
|
|
|
2012-08-01 04:19:04 +02:00
|
|
|
|
An alternative form of vars_prompt allows for hiding input from the user, and may later support
|
|
|
|
|
some other options, but otherwise works equivalently::
|
|
|
|
|
|
|
|
|
|
vars_prompt:
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2012-08-01 04:19:04 +02:00
|
|
|
|
- name: "some_password"
|
|
|
|
|
prompt: "Enter password"
|
2012-12-14 11:56:53 +01:00
|
|
|
|
private: yes
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2012-08-01 04:19:04 +02:00
|
|
|
|
- name: "release_version"
|
|
|
|
|
prompt: "Product release version"
|
2012-12-14 11:56:53 +01:00
|
|
|
|
private: no
|
2012-08-01 04:19:04 +02:00
|
|
|
|
|
2013-03-08 10:08:28 +01:00
|
|
|
|
If `Passlib <http://pythonhosted.org/passlib/>`_ is installed, vars_prompt can also crypt the
|
2013-03-05 17:22:07 +01:00
|
|
|
|
entered value so you can use it, for instance, with the user module to define a password::
|
2013-03-05 16:26:24 +01:00
|
|
|
|
|
|
|
|
|
vars_prompt:
|
2014-02-28 20:18:44 +01:00
|
|
|
|
|
2013-03-05 16:26:24 +01:00
|
|
|
|
- name: "my_password2"
|
|
|
|
|
prompt: "Enter password2"
|
|
|
|
|
private: yes
|
2014-11-07 06:28:04 +01:00
|
|
|
|
encrypt: "sha512_crypt"
|
2013-03-05 16:26:24 +01:00
|
|
|
|
confirm: yes
|
|
|
|
|
salt_size: 7
|
2013-03-05 17:19:14 +01:00
|
|
|
|
|
2013-03-17 16:46:25 +01:00
|
|
|
|
You can use any crypt scheme supported by 'Passlib':
|
2013-03-05 17:22:07 +01:00
|
|
|
|
|
|
|
|
|
- *des_crypt* - DES Crypt
|
|
|
|
|
- *bsdi_crypt* - BSDi Crypt
|
|
|
|
|
- *bigcrypt* - BigCrypt
|
|
|
|
|
- *crypt16* - Crypt16
|
|
|
|
|
- *md5_crypt* - MD5 Crypt
|
|
|
|
|
- *bcrypt* - BCrypt
|
|
|
|
|
- *sha1_crypt* - SHA-1 Crypt
|
|
|
|
|
- *sun_md5_crypt* - Sun MD5 Crypt
|
|
|
|
|
- *sha256_crypt* - SHA-256 Crypt
|
|
|
|
|
- *sha512_crypt* - SHA-512 Crypt
|
|
|
|
|
- *apr_md5_crypt* - Apache’s MD5-Crypt variant
|
|
|
|
|
- *phpass* - PHPass’ Portable Hash
|
|
|
|
|
- *pbkdf2_digest* - Generic PBKDF2 Hashes
|
|
|
|
|
- *cta_pbkdf2_sha1* - Cryptacular’s PBKDF2 hash
|
|
|
|
|
- *dlitz_pbkdf2_sha1* - Dwayne Litzenberger’s PBKDF2 hash
|
|
|
|
|
- *scram* - SCRAM Hash
|
|
|
|
|
- *bsd_nthash* - FreeBSD’s MCF-compatible nthash encoding
|
|
|
|
|
|
2014-02-18 14:23:23 +01:00
|
|
|
|
However, the only parameters accepted are 'salt' or 'salt_size'. You can use your own salt using
|
2013-03-08 10:08:28 +01:00
|
|
|
|
'salt', or have one generated automatically using 'salt_size'. If nothing is specified, a salt
|
2013-03-05 17:22:07 +01:00
|
|
|
|
of size 8 will be generated.
|
2012-08-01 04:19:04 +02:00
|
|
|
|
|
2013-10-05 18:31:16 +02:00
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
|
|
:doc:`playbooks`
|
|
|
|
|
An introduction to playbooks
|
|
|
|
|
:doc:`playbooks_conditionals`
|
|
|
|
|
Conditional statements in playbooks
|
|
|
|
|
:doc:`playbooks_variables`
|
|
|
|
|
All about variables
|
|
|
|
|
`User Mailing List <http://groups.google.com/group/ansible-devel>`_
|
|
|
|
|
Have a question? Stop by the google group!
|
|
|
|
|
`irc.freenode.net <http://irc.freenode.net>`_
|
|
|
|
|
#ansible IRC chat channel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|