Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a98886c7
Commit
a98886c7
authored
Oct 16, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further docs hacking
parent
1801ded3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
docsite/rst/YAMLSyntax.rst
+16
-3
docsite/rst/playbooks2.rst
+10
-0
No files found.
docsite/rst/YAMLSyntax.rst
View file @
a98886c7
...
@@ -38,7 +38,7 @@ A dictionary is represented in a simple ``key:`` and ``value`` form::
...
@@ -38,7 +38,7 @@ A dictionary is represented in a simple ``key:`` and ``value`` form::
---
---
# An employee record
# An employee record
name:
John Eckersberg
name:
Example Developer
job: Developer
job: Developer
skill: Elite
skill: Elite
...
@@ -46,7 +46,7 @@ Dictionaries can also be represented in an abbreviated form if you really want t
...
@@ -46,7 +46,7 @@ Dictionaries can also be represented in an abbreviated form if you really want t
---
---
# An employee record
# An employee record
{name:
John Eckersberg
, job: Developer, skill: Elite}
{name:
Example Developer
, job: Developer, skill: Elite}
.. _truthiness:
.. _truthiness:
...
@@ -63,7 +63,7 @@ has nothing to do with Ansible, but will give you a feel for the format::
...
@@ -63,7 +63,7 @@ has nothing to do with Ansible, but will give you a feel for the format::
---
---
# An employee record
# An employee record
name:
John Eckersberg
name:
Example Developer
job: Developer
job: Developer
skill: Elite
skill: Elite
employed: True
employed: True
...
@@ -80,6 +80,19 @@ has nothing to do with Ansible, but will give you a feel for the format::
...
@@ -80,6 +80,19 @@ has nothing to do with Ansible, but will give you a feel for the format::
That's all you really need to know about YAML to get started writing
That's all you really need to know about YAML to get started writing
`Ansible` playbooks.
`Ansible` playbooks.
Gotchas
-------
While YAML is generally friendly, the following is going to be a YAML syntax error:
foo: somebody said I should put a colon here: so I did
You will want to quote any hash values using colons, like so:
foo: "somebody said I should put a colon here: so I did"
And then the colon will be preserved.
.. seealso::
.. seealso::
:doc:`playbooks`
:doc:`playbooks`
...
...
docsite/rst/playbooks2.rst
View file @
a98886c7
...
@@ -254,6 +254,16 @@ there will be accessible to future tasks::
...
@@ -254,6 +254,16 @@ there will be accessible to future tasks::
action: site_facts
action: site_facts
- action: command echo ${my_custom_fact_can_be_used_now}
- action: command echo ${my_custom_fact_can_be_used_now}
One common useful trick with only_if is to key off the changed result of a last command. As an example::
tasks:
- action: template src=/templates/foo.j2 dest=/etc/foo.conf
- action: command echo 'the file has changed'
only_if: '${last_result.changed}'
$last_result is a variable automatically set by Ansible, and it is a boolean, so there is no need
to test for it against something else with an explicit equals. This assumes Ansible 0.8 and later.
In Ansible 0.8, a few shortcuts are available for testing whether a variable is defined or not::
In Ansible 0.8, a few shortcuts are available for testing whether a variable is defined or not::
tasks:
tasks:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment