mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-13 13:02:00 +00:00
Merge pull request #1158 from t-woerner/idview_fail_to_apply_invalid_hosts
ipaidview: Fail to apply unknown (invalid) hosts
This commit is contained in:
@@ -127,7 +127,7 @@ RETURN = """
|
||||
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, compare_args_ipa, gen_add_del_lists, gen_add_list, \
|
||||
gen_intersection_list
|
||||
gen_intersection_list, ipalib_errors
|
||||
from ansible.module_utils import six
|
||||
|
||||
if six.PY3:
|
||||
@@ -144,6 +144,14 @@ def find_idview(module, name):
|
||||
return _result["result"]
|
||||
|
||||
|
||||
def valid_host(module, name):
|
||||
try:
|
||||
module.ipa_command("host_show", name, {})
|
||||
except ipalib_errors.NotFound:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def gen_args(description, domain_resolution_order):
|
||||
_args = {}
|
||||
if description is not None:
|
||||
@@ -327,6 +335,9 @@ def main():
|
||||
|
||||
# Add members
|
||||
if host_add:
|
||||
for host in host_add:
|
||||
if not valid_host(ansible_module, host):
|
||||
ansible_module.fail_json("Invalid host '%s'" % host)
|
||||
commands.append([name, "idview_apply", {"host": host_add}])
|
||||
|
||||
# Remove members
|
||||
|
||||
Reference in New Issue
Block a user