Make use of yes/no booleans in playbooks

At the moment Ansible prefers yes/no for module booleans, however booleans in playbooks are still using True/False, rather than yes/no. This changes modifies boolean uses in playbooks (and man pages) to favor yes/no rather than True/False.

This change includes:

- Adaptation of documentation and examples to favor yes/no
- Modification to manpage output to favor yes/no (the docsite output already favors yes/no)
This commit is contained in:
Dag Wieers 2012-12-14 11:56:53 +01:00
parent 23f2a7fc7e
commit 66fb7fd9de
12 changed files with 30 additions and 28 deletions

View file

@ -256,13 +256,13 @@ playbooks:
* error reporting if with_items value is unbound * error reporting if with_items value is unbound
* with_items no longer creates lots of tasks, creates one task that makes multiple calls * with_items no longer creates lots of tasks, creates one task that makes multiple calls
* can use host_specific facts inside with_items (see above) * can use host_specific facts inside with_items (see above)
* at the top level of a playbook, set 'gather_facts: False' to skip fact gathering * at the top level of a playbook, set 'gather_facts: no' to skip fact gathering
* first_available_file and with_items used together will now raise an error * first_available_file and with_items used together will now raise an error
* to catch typos, like 'var' for 'vars', playbooks and tasks now yell on invalid parameters * to catch typos, like 'var' for 'vars', playbooks and tasks now yell on invalid parameters
* automatically load (directory_of_inventory_file)/group_vars/groupname and /host_vars/hostname in vars_files * automatically load (directory_of_inventory_file)/group_vars/groupname and /host_vars/hostname in vars_files
* playbook is now colorized, set ANSIBLE_NOCOLOR=1 if you do not like this, does not colorize if not a TTY * playbook is now colorized, set ANSIBLE_NOCOLOR=1 if you do not like this, does not colorize if not a TTY
* hostvars now preserved between plays (regression in 0.5 from 0.4), useful for sharing vars in multinode configs * hostvars now preserved between plays (regression in 0.5 from 0.4), useful for sharing vars in multinode configs
* ignore_errors: True on a task can be used to allow a task to fail and not stop the play * ignore_errors: yes on a task can be used to allow a task to fail and not stop the play
* with_items with the apt/yum module will install/remove/update everything in a single command * with_items with the apt/yum module will install/remove/update everything in a single command
inventory: inventory:

View file

@ -54,6 +54,8 @@ Ansible doesn't really use these too much, but you can also specify a
boolean value (true/false) in several forms:: boolean value (true/false) in several forms::
--- ---
create_key: yes
needs_agent: no
knows_oop: True knows_oop: True
likes_emacs: TRUE likes_emacs: TRUE
uses_cvs: false uses_cvs: false

View file

@ -88,14 +88,14 @@ Support for running things from sudo is also available::
--- ---
- hosts: webservers - hosts: webservers
user: yourname user: yourname
sudo: True sudo: yes
You can also login as you, and then sudo to different users than root:: You can also login as you, and then sudo to different users than root::
--- ---
- hosts: webservers - hosts: webservers
user: yourname user: yourname
sudo: True sudo: yes
sudo_user: postgres sudo_user: postgres
If you need to specify a password to sudo, run `ansible-playbook` with ``--ask-sudo-pass`` (`-K`). If you need to specify a password to sudo, run `ansible-playbook` with ``--ask-sudo-pass`` (`-K`).

View file

@ -67,7 +67,7 @@ write a task that looks like this::
- name: this will not be counted as a failure - name: this will not be counted as a failure
action: command /bin/false action: command /bin/false
ignore_errors: True ignore_errors: yes
Accessing Complex Variable Data Accessing Complex Variable Data
``````````````````````````````` ```````````````````````````````
@ -190,10 +190,10 @@ some other options, but otherwise works equivalently::
vars_prompt: vars_prompt:
- name: "some_password" - name: "some_password"
prompt: "Enter password" prompt: "Enter password"
private: True private: yes
- name: "release_version" - name: "release_version"
prompt: "Product release version" prompt: "Product release version"
private: False private: no
Passing Variables On The Command Line Passing Variables On The Command Line
@ -543,7 +543,7 @@ can turn off fact gathering. This has advantages in scaling ansible in push mod
systems, mainly, or if you are using Ansible on experimental platforms. In any play, just do this:: systems, mainly, or if you are using Ansible on experimental platforms. In any play, just do this::
- hosts: whatever - hosts: whatever
gather_facts: False gather_facts: no
Pull-Mode Playbooks Pull-Mode Playbooks
``````````````````` ```````````````````
@ -663,9 +663,9 @@ if you have a large number of hosts::
# set up the fireball transport # set up the fireball transport
- hosts: all - hosts: all
gather_facts: False gather_facts: no
connection: ssh # or paramiko connection: ssh # or paramiko
sudo: True sudo: yes
tasks: tasks:
- action: fireball - action: fireball
@ -683,8 +683,8 @@ any platform. You will also need gcc and zeromq-devel installed from your packa
--- ---
- hosts: all - hosts: all
sudo: True sudo: yes
gather_facts: False gather_facts: no
connection: ssh connection: ssh
tasks: tasks:
- action: easy_install name=pip - action: easy_install name=pip

View file

@ -3,7 +3,7 @@
- hosts: all - hosts: all
user: root user: root
sudo: True sudo: yes
tasks: tasks:

View file

@ -13,7 +13,7 @@
# could have also have done: # could have also have done:
# user: mdehaan # user: mdehaan
# sudo: True # sudo: yes
# make these variables available inside of templates # make these variables available inside of templates
# for when we use the 'template' action/module later on... # for when we use the 'template' action/module later on...

View file

@ -6,7 +6,7 @@
# see lib/ansible/runner/lookup_plugins/fileglob.py -- they can do basically anything! # see lib/ansible/runner/lookup_plugins/fileglob.py -- they can do basically anything!
- hosts: all - hosts: all
gather_facts: False gather_facts: no
tasks: tasks:

View file

@ -7,8 +7,8 @@
# #
--- ---
- hosts: webservers - hosts: webservers
sudo: True sudo: yes
gather_facts: False gather_facts: no
tasks: tasks:
- name: ensure apt cache is up to date - name: ensure apt cache is up to date
@ -21,9 +21,9 @@
- python-psycopg2 - python-psycopg2
- hosts: webservers - hosts: webservers
sudo: True sudo: yes
sudo_user: postgres sudo_user: postgres
gather_facts: False gather_facts: no
vars: vars:
dbname: myapp dbname: myapp

View file

@ -28,16 +28,16 @@
vars_prompt: vars_prompt:
- name: "some_password" - name: "some_password"
prompt: "Enter password" prompt: "Enter password"
private: True private: yes
- name: "release_version" - name: "release_version"
prompt: "Product release version" prompt: "Product release version"
private: False private: no
- name: "my_password2" - name: "my_password2"
prompt: "Enter password2" prompt: "Enter password2"
private: True private: yes
encrypt: "md5_crypt" encrypt: "md5_crypt"
confirm: True confirm: yes
salt_size: 7 salt_size: 7
salt: "foo" salt: "foo"

View file

@ -13,7 +13,7 @@
# available to tasks and templates made further down in the execution flow. # available to tasks and templates made further down in the execution flow.
- action: shell grep hi /etc/motd - action: shell grep hi /etc/motd
ignore_errors: True ignore_errors: yes
register: motd_result register: motd_result
# and here we access the register. Note that variable is structured data because # and here we access the register. Note that variable is structured data because

View file

@ -21,9 +21,9 @@
{% if v.get('choices') %} {% if v.get('choices') %}
.IR Choices : .IR Choices :
{% for choice in v.get('choices',[]) %}@{ choice }@{% if not loop.last %},{%else%}.{%endif%}{% endfor %}{% endif %} {% for choice in v.get('choices',[]) %}{% if choice == True %}yes{%elif choice == False %}no{% else %}@{ choice }@{% endif %}{% if not loop.last %},{%else%}.{%endif%}{% endfor %}{% endif %}
{% if v.get('required') %}(required){% endif %} {% if v.get('required') %}(required){% endif %}
{% if v.get('default') %} (default: @{ v.get('default') }@){% endif %} {% if v.get('default') %} (default: {% if v.get('default') == True %}yes{%elif v.get('default') == False %}no{% else %}@{ v.get('default') }@){% endif %}{% endif %}
{#---------------------------------------------- #} {#---------------------------------------------- #}
{% if v.get('version_added') %} {% if v.get('version_added') %}
(Added in Ansible version @{ v.get('version_added') }@.) (Added in Ansible version @{ v.get('version_added') }@.)

View file

@ -1,7 +1,7 @@
--- ---
- hosts: all - hosts: all
connection: local connection: local
gather_facts: False gather_facts: no
tasks: tasks:
- action: debug msg="$variable" - action: debug msg="$variable"
@ -9,6 +9,6 @@
connection: local connection: local
vars: vars:
- ugly: var - ugly: var
gather_facts: False gather_facts: no
tasks: tasks:
- action: debug msg="$variable" - action: debug msg="$variable"