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
d1effecb
Commit
d1effecb
authored
Jul 22, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3628 from jlund/yaml-syntax
Minor cleanup of YAML Syntax documentation
parents
86f05f11
be6feee0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
docsite/latest/rst/YAMLSyntax.rst
+12
-12
No files found.
docsite/latest/rst/YAMLSyntax.rst
View file @
d1effecb
...
...
@@ -4,9 +4,9 @@ YAML Syntax
This page provides a basic overview of correct YAML syntax, which is how Ansible
playbooks (our configuration management language) are expressed.
We use YAML because it is easier
to read and write for humans than other common
data formats like XML or JSON. Further, there are libraries available
for reading
and writing YAML in most programming languages.
We use YAML because it is easier
for humans to read and write than other common
data formats like XML or JSON. Further, there are libraries available
in most
programming languages for working with YAML.
You may also wish to read :doc:`playbooks` at the same time to see how this
is used in practice.
...
...
@@ -15,14 +15,14 @@ is used in practice.
YAML Basics
-----------
For
`ansible`
, nearly every YAML file starts with a list.
For
Ansible
, nearly every YAML file starts with a list.
Each item in the list is a list of key/value pairs, commonly
called a "hash" or a "dictionary". So, we need to know how
to write lists and dictionaries in YAML.
There's another small quirk to YAML. All YAML files (regardless of their association with
`ansible` or not) should start with ``---``. This is just a
YAML
format
thing that means "this is the start of a document"
.
Ansible or not) should begin with ``---``. This is part of the
YAML
format
and indicates the start of a document
.
All members of a list are lines beginning at the same indentation level starting
with a ``-`` (dash) character::
...
...
@@ -60,7 +60,7 @@ boolean value (true/false) in several forms::
likes_emacs: TRUE
uses_cvs: false
Let's combine what we learned so far in an arbitary YAML example. This really
Let's combine what we learned so far in an arbit
r
ary YAML example. This really
has nothing to do with Ansible, but will give you a feel for the format::
---
...
...
@@ -76,16 +76,16 @@ has nothing to do with Ansible, but will give you a feel for the format::
- Mango
languages:
ruby: Elite
python: Elite
dotnet: Lame
python: Elite
dotnet: Lame
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
start
writing
`Ansible` playbooks.
Gotchas
-------
While YAML is generally friendly, the following is going to
be
a YAML syntax error:
While YAML is generally friendly, the following is going to
result in
a YAML syntax error:
foo: somebody said I should put a colon here: so I did
...
...
@@ -96,7 +96,7 @@ You will want to quote any hash values using colons, like so:
And then the colon will be preserved.
Further, Ansible uses "{{ var }}" for variables. If a value after a colon starts
with a "{", YAML will think it a dictionary, so you must quote it, like so::
with a "{", YAML will think it
is
a dictionary, so you must quote it, like so::
foo: "{{ variable }}"
...
...
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