Reputation: 254926
How would one specify the multiline strings that have leading spaces on some lines?
If I define a variable as
multiline_str: |
foo
bar
baz
And then write it to a file using
- name: write multiline string
copy: content="{{ multiline_str }}" dest="/path/to/file"
Then the target file contents is
foo
bar
baz
What is the trick here?
Upvotes: 6
Views: 11362
Reputation: 604
You can use the escape notation to keep the leading spaces:
multiline_str: |
\ foo
\ bar
\ baz
Upvotes: 0
Reputation: 498
Had the same problem combined with local_action
.
This works:
- name: write multiline string
local_action:
module: copy
content: "{{ multiline_str }}"
dest: /path/to/file
Upvotes: 1
Reputation: 1510
Try this.
- name: write multiline string
copy:
content: "{{ multiline_str }}"
dest: /path/to/file
Upvotes: 11