community.general/lib/ansible/modules/files
Alex Tsitsimpis c3ab6cb9b1 template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478)
* template: Add integration tests for `lstrip_blocks'

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Fix passing `trim_blocks' inline

Fix passing `trim_blocks' option to the template module as inline
argument. Previously passing the `trim_blocks' option inline instead of
using the YAML dictionary format resulted in it always being set to
`True', even if `trim_blocks=False' was used.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Add option to `lstrip_blocks'

Add option to set `lstrip_blocks' when using the template module to
render Jinja templates. The Jinja documentation suggests that
`trim_blocks' and `lstrip_blocks' is a great combination and the
template module already provides an option for `trim_blocks'.

Note that although `trim_blocks' in Ansible is enabled by default since
version 2.4, in order to avoid breaking things keep `lstrip_blocks'
disabled by default. Maybe in a future version it could be enabled by
default.

This seems to address issue #10725 in a more appropriate way than the
suggested.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Add integration tests for `trim_blocks'

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>

* template: Check Jinja2 support for `lstrip_blocks'

Since the `lstrip_blocks' option was added in Jinja2 version 2.7, raise
an exception when `lstrip_blocks' is set but Jinja2 does not support it.
Check support for `lstrip_blocks' option by checking `jinja2.defaults'
for `LSTRIP_BLOCKS' and do not use `jinja2.__version__' because the
latter is set to `unknown' in some cases, perhaps due to bug in
`pkg_resources' in Python 2.6.6.

Also update option description to state that Jinja2 version >=2.7 is
required.

Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>
2018-03-23 12:05:21 -04:00
..
__init__.py package files 2016-12-08 11:22:22 -05:00
acl.py Remove deprecated get_exception API 2018-02-05 23:39:56 -05:00
archive.py archive: Add support for xz (#34110) 2018-01-22 07:33:07 -05:00
assemble.py now get_url defaults to module temp dir (#36218) 2018-02-20 08:40:45 -05:00
blockinfile.py now get_url defaults to module temp dir (#36218) 2018-02-20 08:40:45 -05:00
copy.py Fix copy for implicit relative paths (#35016) 2018-02-08 00:12:32 -08:00
fetch.py Clean up module documentation (#36909) 2018-03-15 22:15:24 +01:00
file.py File Module docs, adding mode permission example with sticky bit (#36151) 2018-02-14 12:18:13 +00:00
find.py Clean up module documentation (#36909) 2018-03-15 22:15:24 +01:00
ini_file.py ini_file: add allow_no_value param (#24442) 2018-03-05 17:05:41 +01:00
iso_extract.py Update metadata to 1.1 2017-08-15 23:12:08 -07:00
lineinfile.py minor wording changes to remove ambiguity 2018-02-28 16:47:41 -05:00
patch.py Port arg specs from type='str' to type='path' 2017-10-09 21:15:56 -07:00
replace.py now get_url defaults to module temp dir (#36218) 2018-02-20 08:40:45 -05:00
stat.py removed Queen's english from documentation 2017-11-28 10:03:36 +10:00
synchronize.py Add link dest to synchronize module (#32746) 2017-11-13 11:13:25 -05:00
tempfile.py tempfile: PEP8 compliancy, pylint and docs (#30859) 2017-10-30 00:51:19 +01:00
template.py template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
unarchive.py Fix unarchive with strip-components in extra_opts (#37048) 2018-03-07 17:14:51 -08:00
xattr.py Remove deprecated get_exception API 2018-02-05 23:39:56 -05:00
xml.py Fix broken link to w3schools (#34561) 2018-01-08 00:13:39 +01:00