mirror of https://github.com/ansible/ansible.git
lookup_template: added trim_blocks option
* Allow user to control the trimming of blocks while templating * Added tests * Updated documentation and example Fixes: #75962 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/84254/head
parent
f92e99fd8f
commit
1b98ef1722
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- lookup_template - add an option to trim blocks while templating (https://github.com/ansible/ansible/issues/75962).
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
Hello world
|
||||||
|
|
||||||
|
Goodbye
|
@ -0,0 +1,2 @@
|
|||||||
|
Hello world
|
||||||
|
Goodbye
|
@ -0,0 +1,32 @@
|
|||||||
|
# VERIFY trim_blocks
|
||||||
|
- name: Render a template with "trim_blocks" set to False
|
||||||
|
copy:
|
||||||
|
content: "{{ lookup('template', 'trim_blocks.j2', trim_blocks=False) }}"
|
||||||
|
dest: "{{ output_dir }}/trim_blocks_false.templated"
|
||||||
|
register: trim_blocks_false_result
|
||||||
|
|
||||||
|
- name: Get checksum of known good trim_blocks_false.expected
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/files/trim_blocks_false.expected"
|
||||||
|
register: trim_blocks_false_good
|
||||||
|
|
||||||
|
- name: Verify templated trim_blocks_false matches known good using checksum
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "trim_blocks_false_result.checksum == trim_blocks_false_good.stat.checksum"
|
||||||
|
|
||||||
|
- name: Render a template with "trim_blocks" set to True
|
||||||
|
copy:
|
||||||
|
content: "{{ lookup('template', 'trim_blocks.j2', trim_blocks=True) }}"
|
||||||
|
dest: "{{ output_dir }}/trim_blocks_true.templated"
|
||||||
|
register: trim_blocks_true_result
|
||||||
|
|
||||||
|
- name: Get checksum of known good trim_blocks_true.expected
|
||||||
|
stat:
|
||||||
|
path: "{{ role_path }}/files/trim_blocks_true.expected"
|
||||||
|
register: trim_blocks_true_good
|
||||||
|
|
||||||
|
- name: Verify templated trim_blocks_true matches known good using checksum
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "trim_blocks_true_result.checksum == trim_blocks_true_good.stat.checksum"
|
@ -0,0 +1,4 @@
|
|||||||
|
{% if True %}
|
||||||
|
Hello world
|
||||||
|
{% endif %}
|
||||||
|
Goodbye
|
Loading…
Reference in New Issue