community.general/lib/ansible
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
..
cli Compare byte strings to byte strings 2018-03-20 12:04:05 -07:00
compat Enable wildcard import pylint (#35786) 2018-02-06 15:17:49 -08:00
config adds fix for terminal plugins 2018-03-05 08:54:40 -05:00
errors Make AnsibleActionDone a private exception 2018-01-22 23:36:34 -08:00
executor Avoid 2nd processing of facts for actions 2018-03-22 17:27:38 -04:00
galaxy Ansible Galaxy: skel for network role #37241 (#37251) 2018-03-09 13:31:27 -05:00
inventory Fixes #32146 Fixes reconcile inventory to correctly remove hosts from ungrouped 2018-03-20 15:37:39 -04:00
module_utils Changed Azure SecurityRule to use kwargs instead of positional args (#37695) 2018-03-23 20:37:22 +10:00
modules template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
parsing Remove dead code 2018-03-12 12:13:19 -07:00
playbook Fix name parameter templating in include_role module (#36372) 2018-03-20 14:01:48 -04:00
plugins template: Add option to lstrip_blocks' and fix settingtrim_blocks` inline (#37478) 2018-03-23 12:05:21 -04:00
template Fix loader for filters (#37748) 2018-03-22 17:23:10 -04:00
utils Support MSI for ansible on Azure resources (#36634) 2018-03-22 06:01:44 +10:00
vars Fix ansible_lo being used inside of ansible_facts 2018-03-13 12:05:14 -04:00
__init__.py
constants.py Move module_set_locale and module_lang back to global 2018-01-22 18:38:15 -08:00
release.py Fix version in lib/ansible/release.py 2018-02-09 04:47:31 -08:00