Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update YAMLSyntax.rst #14508

Merged
merged 4 commits into from Mar 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 40 additions & 2 deletions docsite/rst/YAMLSyntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ A dictionary is represented in a simple ``key: value`` form (the colon must be f
job: Developer
skill: Elite

More complicated data structures are possible, such as lists of dictionaries, dictionaries whose values are lists or a mix of both::

# Employee records
- martin:
name: Martin D'vloper
job: Developer
skills:
- python
- perl
- pascal
- tabitha:
name: Tabitha Bitumen
job: Developer
skills:
- lisp
- fortran
- erlang

Dictionaries and lists can also be represented in an abbreviated form if you really want to::

---
Expand All @@ -59,6 +77,20 @@ Ansible doesn't really use these too much, but you can also specify a boolean va
likes_emacs: TRUE
uses_cvs: false

Values can span multiple lines using ``|`` or ``>``. Spanning multiple lines using a ``|`` will include the newlines. Using a ``>`` will ignore newlines; it's used to make what would otherwise be a very long line easier to read and edit.
In either case the indentation will be ignored.
Examples are::

include_newlines: |
exactly as you see
will appear these three
lines of poetry

ignore_newlines: >
this is really a
single line of text
despite appearances


Let's combine what we learned so far in an arbitrary YAML example.
This really has nothing to do with Ansible, but will give you a feel for the format::
Expand All @@ -75,9 +107,13 @@ This really has nothing to do with Ansible, but will give you a feel for the for
- Strawberry
- Mango
languages:
ruby: Elite
perl: Elite
python: Elite
dotnet: Lame
pascal: Lame
education: |
4 GCSEs
3 A-Levels
BSc in the Internet of Things

That's all you really need to know about YAML to start writing `Ansible` playbooks.

Expand Down Expand Up @@ -116,6 +152,8 @@ In these cases just use quotes::
YAML Lint (online) helps you debug YAML syntax if you are having problems
`Github examples directory <https://github.com/ansible/ansible-examples>`_
Complete playbook files from the github project source
`Wikipedia YAML syntax reference <https://en.wikipedia.org/wiki/YAML>`_
A good guide to YAML syntax
`Mailing List <http://groups.google.com/group/ansible-project>`_
Questions? Help? Ideas? Stop by the list on Google Groups
`irc.freenode.net <http://irc.freenode.net>`_
Expand Down