1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

handle env exception in gathering even no inject (#43569)

* handle env exception in gathering even no inject

(cherry picked from commit 60e3b9b3527daea6d9fb75a80cc14b35923748f3)
This commit is contained in:
Brian Coca 2018-08-10 15:11:20 -04:00 committed by GitHub
parent 479408330e
commit 9be3a7dde5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- allow gathering env exception to work even when injection is off

View file

@ -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