Skip to content

Commit

Permalink
Fix load_provider returning None on AnsibleFallbackNotFound (#557) (#558
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jk464 authored Sep 6, 2023
1 parent 21c7afa commit c65e32c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/558-load_provider.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Ensure that all connection plugin options that should be strings are actually strings (https://github.com/ansible-collections/ansible.netcommon/pull/549)."
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 c65e32c

Please sign in to comment.