From 9be3a7dde5ca72b1952429a379b725616ba558bd Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 10 Aug 2018 15:11:20 -0400 Subject: [PATCH] handle env exception in gathering even no inject (#43569) * handle env exception in gathering even no inject (cherry picked from commit 60e3b9b3527daea6d9fb75a80cc14b35923748f3) --- changelogs/fragments/env_inject.yml | 2 ++ lib/ansible/playbook/task.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/env_inject.yml diff --git a/changelogs/fragments/env_inject.yml b/changelogs/fragments/env_inject.yml new file mode 100644 index 00000000000..3c36bf22318 --- /dev/null +++ b/changelogs/fragments/env_inject.yml @@ -0,0 +1,2 @@ +bugfixes: + - allow gathering env exception to work even when injection is off diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index b58e7767bf8..b8e02437b8c 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -278,8 +278,9 @@ class Task(Base, Conditional, Taggable, Become): try: env[k] = templar.template(v, convert_bare=False) except AnsibleUndefinedVariable as e: - if self.action in ('setup', 'gather_facts') and 'ansible_env' in to_native(e): - # ignore as fact gathering sets ansible_env + error = to_native(e) + if self.action in ('setup', 'gather_facts') and 'ansible_facts.env' in error or 'ansible_env' in error: + # ignore as fact gathering is required for 'env' facts return raise