Skip to content

Commit

Permalink
Fix load_provider returning None on AnsibleFallbackNotFound (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
jk464 authored and Qalthos committed Aug 3, 2023
1 parent f6d1b9d commit c63aed2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugins/module_utils/network/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ def load_provider(spec, args):
provider = args.get("provider") or {}
for key, value in iteritems(spec):
if key not in provider:
if "fallback" in value:
try:
# Get fallback if defined, and valid
provider[key] = _fallback(value["fallback"])
elif "default" in value:
provider[key] = value["default"]
else:
provider[key] = None
except (basic.AnsibleFallbackNotFound, KeyError):
# Get default if defined, otherwise set to None
provider[key] = value.get("default")
if "authorize" in provider:
# Coerce authorize to provider if a string has somehow snuck in.
provider["authorize"] = boolean(provider["authorize"] or False)
Expand All @@ -491,10 +491,8 @@ def _fallback(fallback):
kwargs = item
else:
args = item
try:
return strategy(*args, **kwargs)
except basic.AnsibleFallbackNotFound:
pass

return strategy(*args, **kwargs)


def generate_dict(spec):
Expand Down

0 comments on commit c63aed2

Please sign in to comment.