From 665e158ec05d49b53e0d057ce5debaf5b500e981 Mon Sep 17 00:00:00 2001 From: brianlycett Date: Tue, 16 Feb 2016 16:40:44 +0000 Subject: [PATCH 1/4] Update YAMLSyntax.rst Updated to include a bit more depth in explaining the YAML, along with a link the Wikipedia page on YAML syntax. --- docsite/rst/YAMLSyntax.rst | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/docsite/rst/YAMLSyntax.rst b/docsite/rst/YAMLSyntax.rst index 8189a6caf6c..4b2ec0535d8 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, or 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:: --- @@ -59,6 +77,17 @@ 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 *>* to include newlines or ignore them:: + + ignore_newlines: > + this is really a + single line of text + despite appearances + + include_newlines: | + exactly as you see + will appear these three + lines of poetry 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:: @@ -75,9 +104,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. @@ -116,6 +149,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 `_ From 4160a3f40b8b4b45547b188473c93aaaa45eff51 Mon Sep 17 00:00:00 2001 From: brianlycett Date: Wed, 24 Feb 2016 15:06:21 +0000 Subject: [PATCH 2/4] Update YAMLSyntax.rst A brief explanation was added regarding multi-line values. --- docsite/rst/YAMLSyntax.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docsite/rst/YAMLSyntax.rst b/docsite/rst/YAMLSyntax.rst index 4b2ec0535d8..b8d19099eb3 100644 --- a/docsite/rst/YAMLSyntax.rst +++ b/docsite/rst/YAMLSyntax.rst @@ -77,18 +77,21 @@ 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 *>* to include newlines or ignore them:: +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:: - ignore_newlines: > - this is really a - single line of text - despite appearances - 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:: From 6c7680b6333985fe1d5d4a9dc27c49c5c3bd0094 Mon Sep 17 00:00:00 2001 From: brianlycett Date: Mon, 29 Feb 2016 16:04:45 +0000 Subject: [PATCH 3/4] Update YAMLSyntax.rst Small updates loosely based on suggestions. :) --- docsite/rst/YAMLSyntax.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsite/rst/YAMLSyntax.rst b/docsite/rst/YAMLSyntax.rst index b8d19099eb3..c5d94e50ff0 100644 --- a/docsite/rst/YAMLSyntax.rst +++ b/docsite/rst/YAMLSyntax.rst @@ -42,7 +42,7 @@ 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, or dictionaries whose values are lists. Or a mix of both:: +More complicated data structures are possible, such as lists of dictionaries, dictionaries whose values are lists or a mix of both:: # Employee records - martin: @@ -77,7 +77,7 @@ 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. +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:: From 18e4a02c25940bbc8ca71a9b24e3a30933b65877 Mon Sep 17 00:00:00 2001 From: brianlycett Date: Mon, 29 Feb 2016 16:06:06 +0000 Subject: [PATCH 4/4] Update YAMLSyntax.rst Ach - it's double backquotes in this markup. --- docsite/rst/YAMLSyntax.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsite/rst/YAMLSyntax.rst b/docsite/rst/YAMLSyntax.rst index c5d94e50ff0..219d78e4143 100644 --- a/docsite/rst/YAMLSyntax.rst +++ b/docsite/rst/YAMLSyntax.rst @@ -77,7 +77,7 @@ 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. +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::