mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-07 13:53:23 +00:00
module_utils/ansible_ipa_server.py: New function ansible_module_get_parsed_ip_addresses
This methods creates a list of ipautil.CheckedIPAddress from the provided ip string list.
This commit is contained in:
@@ -217,3 +217,14 @@ def ds_init_info(ansible_log, fstore, domainlevel, dirsrv_config_file,
|
||||
setup_pkinit=not no_pkinit)
|
||||
|
||||
return ds
|
||||
|
||||
def ansible_module_get_parsed_ip_addresses(ansible_module,
|
||||
param='ip_addresses'):
|
||||
ip_addrs = [ ]
|
||||
for ip in ansible_module.params.get(param):
|
||||
try:
|
||||
ip_parsed = ipautil.CheckedIPAddress(ip)
|
||||
except Exception as e:
|
||||
ansible_module.fail_json(msg="Invalid IP Address %s: %s" % (ip, e))
|
||||
ip_addrs.append(ip_parsed)
|
||||
return ip_addrs
|
||||
|
||||
Reference in New Issue
Block a user