Remove duplicate section, fix a link.

This commit is contained in:
Michael DeHaan 2013-10-04 19:06:20 -04:00
parent d3b916ed0a
commit 6ad43c7268
2 changed files with 3 additions and 21 deletions

View file

@ -19,7 +19,7 @@ as simple as not installing a certain package if the operating system is a parti
or it could be something like performing some cleanup steps if a filesystem is getting full.
This is easy to do in Ansible, with the `when` clause, which contains a Jinja2 expression (see `playbooks_variables`).
It's actually pretty simple:
It's actually pretty simple::
tasks:
- name: "shutdown Debian flavored systems"
@ -103,23 +103,7 @@ there will be accessible to future tasks::
- name: gather site specific fact data
action: site_facts
- command: /usr/bin/thingy
when: "{{ my_custom_fact_just_retrieved_from_the_remote_system }} == '1234'"
The Register Keyword
````````````````````
The 'register' keyword saves the result of a command in a variable. Use "-v" on the playbook command line to see
what kind of values are available, but there are many.
One useful trick with *when* is to key off the result of a last command. As an example::
tasks:
- template: src=/templates/foo.j2 dest=/etc/foo.conf
register: last_result
- command: echo 'the file has changed'
when: last_result.changed
{{ last_result }} is a variable set by the register directive. This assumes Ansible 0.8 and later.
when: my_custom_fact_just_retrieved_from_the_remote_system == '1234'
Applying 'when' to roles and includes
`````````````````````````````````````
@ -216,8 +200,6 @@ The following example shows how to template out a configuration file that was ve
Register Variables
``````````````````
.. versionadded:: 0.7
Often in a playbook it may be useful to store the result of a given command in a variable and access
it later. Use of the command module in this way can in many ways eliminate the need to write site specific facts, for
instance, you could test for the existence of a particular program.

View file

@ -19,7 +19,7 @@ Once understanding variables you'll also want to dig into `playbooks_conditional
Useful things like the "group_by" module
and the "when" conditional can also be used with variables, and to help manage differences between systems.
It's highly recommended that you consult `the Ansible-Examples github repository <http://github.com/ansible/ansible-examples/>_` to see a lot of examples of variables put to use.
It's highly recommended that you consult `the Ansible-Examples github repository <http://github.com/ansible/ansible-examples/>`_ to see a lot of examples of variables put to use.
.. contents::
:depth: 2