1
0
Fork 0
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:
Grzegorz Grasza 2020-06-17 19:45:37 +02:00 committed by GitHub
parent 16ce942448
commit 25123eafc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -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)

View file

@ -43,7 +43,9 @@ from ansible.module_utils.basic import env_fallback, AnsibleFallbackNotFound
def _env_then_dns_fallback(*args, **kwargs):
''' Load value from environment or DNS in that order'''
try:
return env_fallback(*args, **kwargs)
result = env_fallback(*args, **kwargs)
if result == '':
raise AnsibleFallbackNotFound
except AnsibleFallbackNotFound:
# 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