mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-05 22:34:40 +00:00
Merge pull request #208 from t-woerner/ipahost_fix_no_DNS_or_zone
ipahost: Do not fail on missing DNS or zone when no IP address given
This commit is contained in:
@@ -28,6 +28,7 @@ import shutil
|
|||||||
import gssapi
|
import gssapi
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
|
from ipalib import errors as ipalib_errors
|
||||||
from ipalib.config import Env
|
from ipalib.config import Env
|
||||||
from ipalib.constants import DEFAULT_CONFIG, LDAP_GENERALIZED_TIME_FORMAT
|
from ipalib.constants import DEFAULT_CONFIG, LDAP_GENERALIZED_TIME_FORMAT
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ from ansible.module_utils._text import to_text
|
|||||||
from ansible.module_utils.ansible_freeipa_module import temp_kinit, \
|
from ansible.module_utils.ansible_freeipa_module import temp_kinit, \
|
||||||
temp_kdestroy, valid_creds, api_connect, api_command, compare_args_ipa, \
|
temp_kdestroy, valid_creds, api_connect, api_command, compare_args_ipa, \
|
||||||
module_params_get, gen_add_del_lists, encode_certificate, api_get_realm, \
|
module_params_get, gen_add_del_lists, encode_certificate, api_get_realm, \
|
||||||
is_ipv4_addr, is_ipv6_addr
|
is_ipv4_addr, is_ipv6_addr, ipalib_errors
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
@@ -871,7 +871,20 @@ def main():
|
|||||||
|
|
||||||
# Make sure host exists
|
# Make sure host exists
|
||||||
res_find = find_host(ansible_module, name)
|
res_find = find_host(ansible_module, name)
|
||||||
res_find_dnsrecord = find_dnsrecord(ansible_module, name)
|
try:
|
||||||
|
res_find_dnsrecord = find_dnsrecord(ansible_module, name)
|
||||||
|
except ipalib_errors.NotFound as e:
|
||||||
|
msg = str(e)
|
||||||
|
if ip_address is None and \
|
||||||
|
("DNS is not configured" in msg or \
|
||||||
|
"DNS zone not found" in msg):
|
||||||
|
# IP address(es) not given and no DNS support in IPA
|
||||||
|
# -> Ignore failure
|
||||||
|
# IP address(es) not given and DNS zone is not found
|
||||||
|
# -> Ignore failure
|
||||||
|
res_find_dnsrecord = None
|
||||||
|
else:
|
||||||
|
ansible_module.fail_json(msg="%s: %s" % (host, msg))
|
||||||
|
|
||||||
# Create command
|
# Create command
|
||||||
if state == "present":
|
if state == "present":
|
||||||
|
|||||||
@@ -301,6 +301,15 @@
|
|||||||
register: result
|
register: result
|
||||||
failed_when: result.changed
|
failed_when: result.changed
|
||||||
|
|
||||||
|
- name: Absent host01.ihavenodns.info test
|
||||||
|
ipahost:
|
||||||
|
ipaadmin_password: MyPassword123
|
||||||
|
hosts:
|
||||||
|
- name: host01.ihavenodns.info
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
failed_when: result.changed
|
||||||
|
|
||||||
- name: Host absent
|
- name: Host absent
|
||||||
ipahost:
|
ipahost:
|
||||||
ipaadmin_password: MyPassword123
|
ipaadmin_password: MyPassword123
|
||||||
|
|||||||
Reference in New Issue
Block a user