mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix the behavior of ipa modules in case IPA_HOST is empty (#241)
* Fix the behavior of ipa modules in case IPA_HOST is empty The expected behavior, when the env is empty, is to fallback on DNS. Without this fix, if IPA_HOST is empty, there are different errors, depending on urllib version, which additionally confuses the user. Example errors: * host_find: Request failed: <urlopen error no host given> * Failed to connect to None at port 443: [Errno 111] Connection refused", "status": -1, "url": "https:///ipa/session/json * Add a changelog fragment for IPA_HOST fix * Update changelogs/fragments/241-fix-ipa-modules-when-ipa_host-empty.yml Co-authored-by: Sandra McCann <samccann@redhat.com> Co-authored-by: John R Barker <john@johnrbarker.com> Co-authored-by: Sandra McCann <samccann@redhat.com>
This commit is contained in:
parent
16ce942448
commit
25123eafc7
2 changed files with 5 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ipa modules - fix error when IPA_HOST is empty and fallback on DNS (https://github.com/ansible-collections/community.general/pull/241)
|
|
@ -43,7 +43,9 @@ from ansible.module_utils.basic import env_fallback, AnsibleFallbackNotFound
|
||||||
def _env_then_dns_fallback(*args, **kwargs):
|
def _env_then_dns_fallback(*args, **kwargs):
|
||||||
''' Load value from environment or DNS in that order'''
|
''' Load value from environment or DNS in that order'''
|
||||||
try:
|
try:
|
||||||
return env_fallback(*args, **kwargs)
|
result = env_fallback(*args, **kwargs)
|
||||||
|
if result == '':
|
||||||
|
raise AnsibleFallbackNotFound
|
||||||
except AnsibleFallbackNotFound:
|
except AnsibleFallbackNotFound:
|
||||||
# If no host was given, we try to guess it from IPA.
|
# If no host was given, we try to guess it from IPA.
|
||||||
# The ipa-ca entry is a standard entry that IPA will have set for
|
# The ipa-ca entry is a standard entry that IPA will have set for
|
||||||
|
|
Loading…
Reference in a new issue