diff --git a/lib/ansible/utils/template.py b/lib/ansible/utils/template.py index 9521f2f2ece..5146057dac9 100644 --- a/lib/ansible/utils/template.py +++ b/lib/ansible/utils/template.py @@ -340,6 +340,8 @@ def template_from_string(basedir, data, vars, fail_on_undefined=False): try: t = environment.from_string(data) + except TemplateSyntaxError, e: + raise errors.AnsibleError("template error while templating string: %s" % str(e)) except Exception, e: if 'recursion' in str(e): raise errors.AnsibleError("recursive loop detected in template string: %s" % data) diff --git a/test/integration/Makefile b/test/integration/Makefile index 4bccc8cd9f1..56e35d7c8b1 100644 --- a/test/integration/Makefile +++ b/test/integration/Makefile @@ -26,6 +26,7 @@ parsing: ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags common,scenario2; [ $$? -eq 3 ] ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags common,scenario3; [ $$? -eq 3 ] ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags common,scenario4; [ $$? -eq 3 ] + ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags common,scenario5; [ $$? -eq 3 ] ansible-playbook good_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) includes: diff --git a/test/integration/roles/test_bad_parsing/tasks/main.yml b/test/integration/roles/test_bad_parsing/tasks/main.yml index fae01f2ee9d..3899821de6f 100644 --- a/test/integration/roles/test_bad_parsing/tasks/main.yml +++ b/test/integration/roles/test_bad_parsing/tasks/main.yml @@ -49,5 +49,7 @@ failed_when: False tags: scenario4 - +- name: test that a missing/malformed jinja2 filter fails + debug: msg="{{output_dir|badfiltername}}" + tags: scenario5 diff --git a/test/integration/test_group_by.yml b/test/integration/test_group_by.yml index 6385c1f5ad7..0f4ff413879 100644 --- a/test/integration/test_group_by.yml +++ b/test/integration/test_group_by.yml @@ -92,7 +92,7 @@ - name: set a fact to check that we ran this play set_fact: genus_LAMA=true -- hosts: '{{genus' +- hosts: 'genus' gather_facts: false tasks: - name: no hosts should match this group