ansible/examples/playbooks/prompts.yml
Petros Moisiadis c717934b7e Improved 'vars_prompt' syntax to support prompt text and (non-)private input
An example of the new syntax:

vars_prompt:
 - name: 'secret_variable_name"
   prompt: "Enter secret value: "
   private: "yes"
 - name: "nonsecret_variable_name"
   prompt: "Enter non-secret value: "
   private: "no"
2012-07-27 19:00:48 -04:00

46 lines
1.4 KiB
YAML

---
# it is possible to ask for variables from the user at the start
# of a playbook run, for example, as part of a release script.
- hosts: all
user: root
# regular variables are a dictionary of keys and values
vars:
this_is_a_regular_var: 'moo'
so_is_this: 'quack'
# alternatively, they can ALSO be passed in from the outside:
# ansible-playbook foo.yml --extra-vars="foo=100 bar=101"
# or through external inventory scripts (see online API docs)
# prompted variables are a list of variable names and a description
# that will be presented to the user, or a list of variable dictionaries
# with the following accepted keys / value types:
# 'name' / text
# 'prompt' / text (optional)
# 'private' / boolean (optional)
# prompted variables as key/value pairs:
vars_prompt:
release_version: "product release version"
# prompted variables as a list of variable dictionaries:
# vars_prompt:
# - name: "some_password"
# prompt: "Enter password: "
# private: True
# - name: "release_version"
# prompt: "Product release version: "
# private: False
# this is just a simple example to show that vars_prompt works, but
# you might ask for a tag to use with the git module or perhaps
# a package version to use with the yum module.
tasks:
- name: imagine this did something interesting with $release_version
action: shell echo foo >> /tmp/$release_version-$alpha