From d06911bc73f073c03fc9150e690ce3d76b5723bf Mon Sep 17 00:00:00 2001 From: Gilles M Date: Wed, 20 Nov 2024 18:55:17 +0100 Subject: [PATCH] Fix exception with 'skipped' test (#4406) Co-authored-by: MARGERIE Gilles --- examples/playbooks/rule-jinja-pass.yml | 15 +++++++++++++++ src/ansiblelint/rules/jinja.py | 2 ++ 2 files changed, 17 insertions(+) diff --git a/examples/playbooks/rule-jinja-pass.yml b/examples/playbooks/rule-jinja-pass.yml index 6944611d97..e3b7e3be01 100644 --- a/examples/playbooks/rule-jinja-pass.yml +++ b/examples/playbooks/rule-jinja-pass.yml @@ -88,3 +88,18 @@ - name: Bug https://github.com/ansible/ansible-lint/issues/3908 ansible.builtin.debug: msg: "{{ foo | ansible.builtin.mandatory(msg='My message') }}" + +- name: Bugs https://github.com/ansible/ansible-lint/issues/4338 + hosts: localhost + tasks: + - name: Test task + ansible.builtin.debug: + msg: "Hello, world!" + when: false + register: result + + - name: Test task 2 + vars: + counter: "{{ result is skipped | ternary(1, 2) }}" + ansible.builtin.debug: + msg: "Hello, world {{ counter }}!" diff --git a/src/ansiblelint/rules/jinja.py b/src/ansiblelint/rules/jinja.py index e0f69c4582..324fa07b64 100644 --- a/src/ansiblelint/rules/jinja.py +++ b/src/ansiblelint/rules/jinja.py @@ -65,6 +65,8 @@ class Token(NamedTuple): r"Unrecognized type <> for (.*) filter $", # https://github.com/ansible/ansible-lint/issues/3155 r"^The '(.*)' test expects a dictionary$", + # https://github.com/ansible/ansible-lint/issues/4338 + r"An unhandled exception occurred while templating (.*). Error was a , original message: The (.*) test expects a dictionary$", ], ), flags=re.MULTILINE | re.DOTALL,