ansible/html/_sources/YAMLScripts.txt

84 lines
2 KiB
Text
Raw Normal View History

2012-03-09 04:52:16 +01:00
YAML Format
===========
2012-03-07 17:35:18 +01:00
2012-03-08 19:36:47 +01:00
This page provides a basic overview of correct YAML syntax, which is how Ansible
playbooks (our configuration management language) are expressed.
You may also wish to read playbook examples and will quickly pick this up from those.
2012-03-07 17:35:18 +01:00
YAML Basics
-----------
2012-03-09 04:52:16 +01:00
For `ansible`, every YAML file must be a list at it's root-most
2012-03-07 17:35:18 +01:00
element. Each item in the list is a dictionary. These dictionaries
2012-03-09 04:52:16 +01:00
represent all the options you can use to write an `ansible` file. In
2012-03-07 17:35:18 +01:00
addition, all YAML files (regardless of their association with
`ansible` or not) should start with ``---``.
In YAML a list can be represented in two ways. In one way all members
2012-03-09 04:52:16 +01:00
of a list are lines beginning at the same indenta`tion level starting
2012-03-07 17:35:18 +01:00
with a ``-`` character::
---
# A list of tasty fruits
- Apple
- Orange
- Strawberry
- Mango
In the second way a list is represented as comma separated elements
surrounded by square brackets. Newlines are permitted between
elements::
---
# A list of tasty fruits
[apple, orange, banana, mango]
A dictionary is represented in a simple ``key:`` and ``value`` form::
---
# An employee record
name: John Eckersberg
job: Developer
skill: Elite
Like lists, dictionaries can be represented in an abbreviated form::
---
# An employee record
{name: John Eckersberg, job: Developer, skill: Elite}
.. _truthiness:
You can specify a boolean value (true/false) in several forms::
---
knows_oop: True
likes_emacs: TRUE
uses_cvs: false
Finally, you can combine these data structures::
---
# An employee record
name: John Eckersberg
job: Developer
skill: Elite
employed: True
foods:
- Apple
- Orange
- Strawberry
- Mango
languages:
ruby: Elite
python: Elite
dotnet: Lame
That's all you really need to know about YAML to get started writing
2012-03-08 19:36:47 +01:00
`Ansible` playbooks.
2012-03-07 17:35:18 +01:00
.. seealso::
`YAMLLint <http://yamllint.com/>`_
YAML Lint gets the lint out of your YAML