Last active
August 29, 2015 14:18
-
-
Save halberom/82d1280d14d85d04e956 to your computer and use it in GitHub Desktop.
ansible - examples of the different forms of yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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