diff --git a/docsite/rst/YAMLSyntax.rst b/docsite/rst/YAMLSyntax.rst index 97698d68964..39cc3b2d589 100644 --- a/docsite/rst/YAMLSyntax.rst +++ b/docsite/rst/YAMLSyntax.rst @@ -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:: --- @@ -58,6 +76,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:: @@ -74,9 +106,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. @@ -115,6 +151,8 @@ In these cases just use quotes:: YAML Lint (online) helps you debug YAML syntax if you are having problems `Github examples directory `_ Complete playbook files from the github project source + `Wikipedia YAML syntax reference `_ + A good guide to YAML syntax `Mailing List `_ Questions? Help? Ideas? Stop by the list on Google Groups `irc.freenode.net `_