Ipa bugfixes (#3421)
* ipa_group: Fix: 'list' object has no attribute 'get' * ipa_hbacrule: Fix: 'list' object has no attribute 'get' * ipa_host: Fix: 'list' object has no attribute 'get' * ipa_hostgroup: Fix: 'list' object has no attribute 'get' * ipa_role: Fix: 'list' object has no attribute 'get' * ipa_sudocmd: Fix: 'list' object has no attribute 'get' * ipa_sudocmdgroup: Fix: 'list' object has no attribute 'get' * ipa_sudorule: Fix: 'list' object has no attribute 'get' * ipa_user: Fix: 'list' object has no attribute 'get' * ipa_sudorule: Fix: invalid 'cn': Only one value is allowed * ipa_hostgroup: module returns changed if assigned hosts or hostgroups are not in lowercase
This commit is contained in:
parent
0f6aa07d88
commit
9814136d3e
9 changed files with 24 additions and 3 deletions
|
@ -210,6 +210,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -241,6 +241,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -234,6 +234,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -187,6 +187,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
@ -285,11 +287,13 @@ def ensure(module, client):
|
|||
client.hostgroup_mod(name=name, item=data)
|
||||
|
||||
if host is not None:
|
||||
changed = modify_if_diff(module, name, ipa_hostgroup.get('member_host', []), host,
|
||||
changed = modify_if_diff(module, name, ipa_hostgroup.get('member_host', []),
|
||||
[item.lower() for item in host],
|
||||
client.hostgroup_add_host, client.hostgroup_remove_host) or changed
|
||||
|
||||
if hostgroup is not None:
|
||||
changed = modify_if_diff(module, name, ipa_hostgroup.get('member_hostgroup', []), hostgroup,
|
||||
changed = modify_if_diff(module, name, ipa_hostgroup.get('member_hostgroup', []),
|
||||
[item.lower() for item in hostgroup],
|
||||
client.hostgroup_add_hostgroup, client.hostgroup_remove_hostgroup) or changed
|
||||
|
||||
else:
|
||||
|
|
|
@ -217,6 +217,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -167,6 +167,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -174,6 +174,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
|
@ -226,6 +226,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
@ -348,7 +350,8 @@ def modify_if_diff(module, name, ipa_list, module_list, add_method, remove_metho
|
|||
def category_changed(module, client, category_name, ipa_sudorule):
|
||||
if ipa_sudorule.get(category_name, None) == ['all']:
|
||||
if not module.check_mode:
|
||||
client.sudorule_mod(name=ipa_sudorule.get('cn'), item={category_name: None})
|
||||
# cn is returned as list even with only a single value.
|
||||
client.sudorule_mod(name=ipa_sudorule.get('cn')[0], item={category_name: None})
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -212,6 +212,8 @@ class IPAClient:
|
|||
if isinstance(result, list):
|
||||
if len(result) > 0:
|
||||
return result[0]
|
||||
else:
|
||||
return {}
|
||||
return result
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue