summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/template/templates (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add new comment attribute to template plugin (#69253)Hossein Zolfi2021-08-121-0/+3
| | | | | | | | | * Add new comment attribute to template plugin Add comment_start_string and comment_end_string attribute to template plugin Co-authored-by: Hossein Zolfi <h.zolfi@inside.sahab.ir>
* Globals should be accessible when importing a template without the context ↵Martin Krizek2021-08-052-0/+5
| | | | | (#75384) Fixes #75371
* Local vars should have highest precedence in AnsibleJ2Vars (#72830)Martin Krizek2021-01-268-0/+26
| | | | | | | | | | | | | | | | | | Ability to add local variables into AnsibleJ2Vars was added in 18a9eff11f0a6e51b17405ce596bd9ff7e676320 to fix #6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for #6653. Fixes #72262 Fixes #72615 ci_complete
* Prevent templating unused variables for {%include%} (#68749)Martin Krizek2020-04-142-0/+3
| | | Fixes #68699
* template: add additional variable for dest path (#52015)Abhijeet Kasurde2019-02-191-0/+1
| | | | | Signed-off-by: Dustin Spicuzza <dustin@virtualroadside.com> Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* Allow specifying the output encoding in the template module (#42171)Julien Champseix2018-07-251-0/+1
| | | | | | | | | | Allow specifying the source and destination files' encodings in the template module * Added output_encoding to the template module, default to utf-8 * Added documentation for the new variables * Leveraged the encoding argument on to_text() and to_bytes() to keep the implementation as simple as possible * Added integration tests with files in utf-8 and windows-1252 encodings, testing all combinations * fix bad smell test by excluding windows-1252 files from the utf8 checks * fix bad smell test by excluding valid files from the smart quote test
* Add tests for template with non-ascii filenamesToshio Kuratomi2018-04-261-0/+1
| | | | | | | This is a test in response to #27262 but I could not provoke the error so it only shows that the current code is working with non-ascii filenames in this case. It doesn't show whether there's some other bug somewhere.
* template: Add option to `lstrip_blocks' and fix setting`trim_blocks` inline ↵Alex Tsitsimpis2018-03-232-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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>
* Fix jinja2>=2.9 nested include vars (#35099)Martin Krizek2018-02-073-0/+8
| | | | | | | This fixes a bug when parent's local vars where not available in nested includes. The bug can only be seen with jinja>=2.9 which changes how the variable scopes work. Fixes #34886
* rm unused test template in template intg testsAdrian Likins2017-08-121-3/+0
| | | | | introduced in 501fc7a248c4ad09c2593a200b3fbbdff0e48c70 based on my patch.
* template: fix KeyError: 'undefined variable: 0 (#27972)Zac Medico2017-08-106-0/+16
| | | | | | | | | | | | | | | | | | | * template: fix KeyError: 'undefined variable: 0 For compatibility with the Context.get_all() implementation in jinja 2.9, make AnsibleJ2Vars implement collections.Mapping. Also, make AnsibleJ2Template.newcontext() handle dict type for the 'vars' parameter. See: https://github.com/pallets/jinja/commit/d67f0fd4cc2a4af08f51f4466150d49da7798729 Fixes: https://github.com/ansible/ansible/issues/20494 * add units/template/test_vars * intg tests for jinja-2.9 issues like 20494 test cases here are based on https://github.com/ansible/ansible/issues/20494#issue-202108318
* Windows: Use the correct newline sequence for the platform (#21846)Dag Wieers2017-03-242-0/+6
| | | | | | | | | | | | | This change to the template action plugin make template use the platform's native newline_sequence for Jinja. We also added the option `newline_sequence` to change the newline sequence using by Jinja if you need to use another newline sequence than the platform default. This was previously discussed in https://github.com/ansible/ansible/issues/16255#issuecomment-278289414 And also relates to issue #21128
* Don't restrict local jinja2 variables to those that start with l_James Cammarata2017-01-202-0/+5
| | | | | | | | | | Per a change in jinja2 2.9, local variables no longer are prefixed with l_, so this updates AnsibleJ2Vars to pull in all locals (while excluding some) regardless of name. Fixes #20063 (cherry picked from commit 4d49b317929b86e1fc1b0cbace825ff73b372dc7)
* Migrate Linux CI roles to test targets. (#17997)Matt Clay2016-10-132-0/+4