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-24 16:43:29 +02:00
|
|
|
# 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:
|
2012-04-03 02:35:51 +02:00
|
|
|
vars_prompt:
|
|
|
|
release_version: "product release version"
|
|
|
|
|
2012-07-24 16:43:29 +02:00
|
|
|
# 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
|
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.
|
|
|
|
|
2012-07-24 16:43:29 +02:00
|
|
|
tasks:
|
2012-04-03 02:35:51 +02:00
|
|
|
- name: imagine this did something interesting with $release_version
|
2012-04-03 02:37:59 +02:00
|
|
|
action: shell echo foo >> /tmp/$release_version-$alpha
|
2012-04-03 02:35:51 +02:00
|
|
|
|