You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/lib/ansible
Alex Tsitsimpis c3ab6cb9b1 template: Add option to `lstrip_blocks' and fix setting`trim_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>
8 years ago
..
cli Compare byte strings to byte strings 8 years ago
compat Enable wildcard import pylint (#35786) 8 years ago
config adds fix for terminal plugins 8 years ago
errors Make AnsibleActionDone a private exception 8 years ago
executor Avoid 2nd processing of facts for actions 8 years ago
galaxy Ansible Galaxy: skel for network role #37241 (#37251) 8 years ago
inventory Fixes #32146 Fixes reconcile inventory to correctly remove hosts from ungrouped 8 years ago
module_utils Changed Azure SecurityRule to use kwargs instead of positional args (#37695) 8 years ago
modules template: Add option to `lstrip_blocks' and fix setting`trim_blocks` inline (#37478) 8 years ago
parsing Remove dead code 8 years ago
playbook Fix name parameter templating in include_role module (#36372) 8 years ago
plugins template: Add option to `lstrip_blocks' and fix setting`trim_blocks` inline (#37478) 8 years ago
template Fix loader for filters (#37748) 8 years ago
utils Support MSI for ansible on Azure resources (#36634) 8 years ago
vars Fix ansible_lo being used inside of ansible_facts 8 years ago
__init__.py Fix ziploader for the cornercase of ansible invoking ansible. 10 years ago
constants.py Move module_set_locale and module_lang back to global 8 years ago
release.py Fix version in lib/ansible/release.py 8 years ago