mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.3 KiB
ReStructuredText
108 lines
3.3 KiB
ReStructuredText
11 years ago
|
Prompts
|
||
|
=======
|
||
13 years ago
|
|
||
11 years ago
|
When running a playbook, you may wish to prompt the user for certain input, and can
|
||
|
do so with the 'vars_prompt' section.
|
||
12 years ago
|
|
||
11 years ago
|
A common use for this might be for asking for sensitive data that you do not want to record.
|
||
13 years ago
|
|
||
11 years ago
|
This has uses beyond security, for instance, you may use the same playbook for all
|
||
13 years ago
|
software releases and would prompt for a particular release version
|
||
11 years ago
|
in a push-script.
|
||
|
|
||
|
Here is a most basic example::
|
||
13 years ago
|
|
||
|
---
|
||
|
- hosts: all
|
||
11 years ago
|
remote_user: root
|
||
11 years ago
|
|
||
13 years ago
|
vars:
|
||
|
from: "camelot"
|
||
11 years ago
|
|
||
13 years ago
|
vars_prompt:
|
||
9 years ago
|
- name: "name"
|
||
|
prompt: "what is your name?"
|
||
|
- name: "quest"
|
||
|
prompt: "what is your quest?"
|
||
|
- name: "favcolor"
|
||
|
prompt: "what is your favorite color?"
|
||
13 years ago
|
|
||
7 years ago
|
|
||
8 years ago
|
.. note::
|
||
7 years ago
|
Prompts for individual ``vars_prompt`` variables will be skipped for any variable that is already defined through the command line ``--extra-vars`` option, or when running from a non-interactive session (such as cron or Ansible Tower). See :ref:`passing_variables_on_the_command_line` in the /Variables/ chapter.
|
||
8 years ago
|
|
||
12 years ago
|
If you have a variable that changes infrequently, it might make sense to
|
||
11 years ago
|
provide a default value that can be overridden. This can be accomplished using
|
||
12 years ago
|
the default argument::
|
||
|
|
||
|
vars_prompt:
|
||
11 years ago
|
|
||
12 years ago
|
- name: "release_version"
|
||
|
prompt: "Product release version"
|
||
|
default: "1.0"
|
||
|
|
||
12 years ago
|
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:
|
||
11 years ago
|
|
||
12 years ago
|
- name: "some_password"
|
||
|
prompt: "Enter password"
|
||
12 years ago
|
private: yes
|
||
11 years ago
|
|
||
12 years ago
|
- name: "release_version"
|
||
|
prompt: "Product release version"
|
||
12 years ago
|
private: no
|
||
12 years ago
|
|
||
7 years ago
|
If `Passlib <https://passlib.readthedocs.io/en/stable/>`_ is installed, vars_prompt can also encrypt the
|
||
12 years ago
|
entered value so you can use it, for instance, with the user module to define a password::
|
||
12 years ago
|
|
||
|
vars_prompt:
|
||
11 years ago
|
|
||
12 years ago
|
- name: "my_password2"
|
||
|
prompt: "Enter password2"
|
||
|
private: yes
|
||
10 years ago
|
encrypt: "sha512_crypt"
|
||
12 years ago
|
confirm: yes
|
||
|
salt_size: 7
|
||
12 years ago
|
|
||
12 years ago
|
You can use any crypt scheme supported by 'Passlib':
|
||
12 years ago
|
|
||
|
- *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
|
||
7 years ago
|
- *apr_md5_crypt* - Apache's MD5-Crypt variant
|
||
|
- *phpass* - PHPass' Portable Hash
|
||
12 years ago
|
- *pbkdf2_digest* - Generic PBKDF2 Hashes
|
||
7 years ago
|
- *cta_pbkdf2_sha1* - Cryptacular's PBKDF2 hash
|
||
|
- *dlitz_pbkdf2_sha1* - Dwayne Litzenberger's PBKDF2 hash
|
||
12 years ago
|
- *scram* - SCRAM Hash
|
||
7 years ago
|
- *bsd_nthash* - FreeBSD's MCF-compatible nthash encoding
|
||
12 years ago
|
|
||
11 years ago
|
However, the only parameters accepted are 'salt' or 'salt_size'. You can use your own salt using
|
||
12 years ago
|
'salt', or have one generated automatically using 'salt_size'. If nothing is specified, a salt
|
||
12 years ago
|
of size 8 will be generated.
|
||
12 years ago
|
|
||
11 years ago
|
.. 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
|
||
|
|
||
|
|
||
|
|