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:
parent
479408330e
commit
9be3a7dde5
2 changed files with 5 additions and 2 deletions
2
changelogs/fragments/env_inject.yml
Normal file
2
changelogs/fragments/env_inject.yml
Normal file
|
@ -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:
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue