Skip to content

Instantly share code, notes, and snippets.

@halberom
Last active August 29, 2015 14:18
Show Gist options
  • Save halberom/82d1280d14d85d04e956 to your computer and use it in GitHub Desktop.
Save halberom/82d1280d14d85d04e956 to your computer and use it in GitHub Desktop.
ansible - examples of the different forms of yaml
---
- hosts: foo
tasks:
- name: single line plain style
file: path=/tmp/foo state=touch
- name: multi line plain style
file: path=/tmp/foo
state=absent
#- name: alternative multi line plain style
# file:
# path=/tmp/foo
# state=absent
- name: multi line double quoted style
file: "path=/tmp/foo
state=touch"
- name: multi line single quoted style
file: 'path=/tmp/foo
state=absent'
# With the yaml 'folded' style, anything in a new line (and indented) below a >
# is essentially a single string that has been wrapped. new line chars are not
# preserved unless the line is further indented or is an empty line.
- name: multi line with folded style
file: >
path=/tmp/foo
state=touch
- name: multi line with yaml dict
file:
path: /tmp/foo
state: absent
- name: using folded style to insert content
copy:
dest: /tmp/foo
content: >
this is a string
that will be one
line in the file
- shell: cat /tmp/foo
register: result
- debug: var=result
- name: using literal style to insert content
copy:
dest: /tmp/foo
content: |
this is a string
that will have
new lines preserved
- shell: cat /tmp/foo
register: result
- debug: var=result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment