ansible/examples/playbooks/prompts.yml

61 lines
1.6 KiB
YAML
Raw Normal View History

2012-04-03 02:35:51 +02:00
---
# 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'
2012-04-03 02:37:59 +02:00
# 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)
2012-04-03 02:35:51 +02:00
2012-07-28 01:00:29 +02:00
# here's basic mode prompting. Specify a hash of variable names and a prompt for
# each.
#
# vars_prompt:
# release_version: "product release version"
2012-08-07 02:00:31 +02:00
# prompts can also be specified like this, allowing for hiding the prompt as
2012-07-28 01:00:29 +02:00
# entered. In the future, this may also be used to support crypted variables
2012-04-03 02:35:51 +02:00
vars_prompt:
2012-07-28 01:00:29 +02:00
- name: "some_password"
prompt: "Enter password"
private: yes
2013-01-18 12:00:57 +01:00
2012-07-28 01:00:29 +02:00
- name: "release_version"
prompt: "Product release version"
2013-01-18 12:00:57 +01:00
default: "my_default_version"
private: no
2012-08-09 16:56:40 +02:00
- name: "my_password2"
prompt: "Enter password2"
private: yes
2012-08-09 16:56:40 +02:00
encrypt: "md5_crypt"
confirm: yes
2012-08-09 16:56:40 +02:00
salt_size: 7
salt: "foo"
2012-04-03 02:35:51 +02:00
# 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:
2013-05-05 19:41:21 +02:00
- name: imagine this did something interesting with {{release_version}}
action: shell echo foo >> /tmp/{{release_version}}-alpha
2012-04-03 02:35:51 +02:00
- name: look we crypted a password
2013-05-05 19:41:21 +02:00
action: shell echo my password is {{my_password2}}