summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVirgil Dupras <hsoft@hardcoded.net>2016-11-29 16:23:06 -0500
committerBrian Coca <brian.coca+git@gmail.com>2016-11-29 16:23:23 -0500
commit4854705267968e478b1026b3d6e9cb9a3a0006a2 (patch)
treec75afa048c2c10b6f58bc556fdf0a09e69d09276 /test
parentff60245e2b3767b13745c38e20fd3e9270ee2ff6 (diff)
downloadansible-4854705267968e478b1026b3d6e9cb9a3a0006a2.tar.gz
Fix regression in jinja2 include search path (#18617)
* Fix regression in jinja2 include search path Since commit 3c39bb5, the 'ansible_search_path' variable is used to set jinja2's search path for {% include %} directives. However, this path is the the proper one because our templates live in 'templates' subdirs in our search path. This is a regression because previously, our include search path would include the dirname of the currently interpreted file, which worked most of the time. fixes #18526 * Fix template lookup search path Improve fix in commit c96c853 so that the search path contain both template-suffixed paths as well as original paths. ref PR #18617 * Add integration test for template lookups Tests regression at #18526 This test fails on current devel branch and succeeds on PR #18617 (cherry picked from commit bf48383610e2edb1f10ebdda820b9fa0d81dedda)
Diffstat (limited to 'test')
-rw-r--r--test/integration/roles/test_lookups/tasks/main.yml11
-rw-r--r--test/integration/targets/lookups/templates/hello.txt1
-rw-r--r--test/integration/targets/lookups/templates/world.txt1
3 files changed, 13 insertions, 0 deletions
diff --git a/test/integration/roles/test_lookups/tasks/main.yml b/test/integration/roles/test_lookups/tasks/main.yml
index f861ceaede..8ca6f956ff 100644
--- a/test/integration/roles/test_lookups/tasks/main.yml
+++ b/test/integration/roles/test_lookups/tasks/main.yml
@@ -268,3 +268,14 @@
- product.results[6]['item'] == ["C", "1"]
- product.results[7]['item'] == ["C", "2"]
- product.results[8]['item'] == ["C", "3"]
+
+# Template lookups
+
+# ref #18526
+- name: Test that we have a proper jinja search path in template lookup
+ set_fact:
+ hello_world: "{{ lookup('template', 'hello.txt') }}"
+
+- assert:
+ that:
+ - "hello_world|trim == 'Hello world!'"
diff --git a/test/integration/targets/lookups/templates/hello.txt b/test/integration/targets/lookups/templates/hello.txt
new file mode 100644
index 0000000000..be15a4f333
--- /dev/null
+++ b/test/integration/targets/lookups/templates/hello.txt
@@ -0,0 +1 @@
+Hello {% include 'world.txt' %}!
diff --git a/test/integration/targets/lookups/templates/world.txt b/test/integration/targets/lookups/templates/world.txt
new file mode 100644
index 0000000000..cc628ccd10
--- /dev/null
+++ b/test/integration/targets/lookups/templates/world.txt
@@ -0,0 +1 @@
+world