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

* handle env exception in gathering even no inject

(cherry picked from commit 60e3b9b3527daea6d9fb75a80cc14b35923748f3)
pull/43980/head
Brian Coca 6 years ago committed by GitHub
parent 479408330e
commit 9be3a7dde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -278,8 +278,9 @@ class Task(Base, Conditional, Taggable, Become):
try: try:
env[k] = templar.template(v, convert_bare=False) env[k] = templar.template(v, convert_bare=False)
except AnsibleUndefinedVariable as e: except AnsibleUndefinedVariable as e:
if self.action in ('setup', 'gather_facts') and 'ansible_env' in to_native(e): error = to_native(e)
# ignore as fact gathering sets ansible_env 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 return
raise raise

Loading…
Cancel
Save