mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-02 04:44:42 +00:00
Merge pull request #637 from rjeffman/ipaconfig_missing_params
config: Fix data returned from module.
This commit is contained in:
@@ -252,7 +252,7 @@ from ansible.module_utils.ansible_freeipa_module import \
|
|||||||
|
|
||||||
|
|
||||||
def config_show(module):
|
def config_show(module):
|
||||||
_result = module.ipa_command_no_name("config_show", {})
|
_result = module.ipa_command_no_name("config_show", {"all": True})
|
||||||
|
|
||||||
return _result["result"]
|
return _result["result"]
|
||||||
|
|
||||||
@@ -388,19 +388,18 @@ def main():
|
|||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
exit_args = {}
|
exit_args = {}
|
||||||
res_show = None
|
|
||||||
|
|
||||||
# Connect to IPA API
|
# Connect to IPA API
|
||||||
with ansible_module.ipa_connect():
|
with ansible_module.ipa_connect():
|
||||||
|
|
||||||
|
result = config_show(ansible_module)
|
||||||
if params:
|
if params:
|
||||||
res_show = config_show(ansible_module)
|
|
||||||
params = {
|
params = {
|
||||||
k: v for k, v in params.items()
|
k: v for k, v in params.items()
|
||||||
if k not in res_show or res_show[k] != v
|
if k not in result or result[k] != v
|
||||||
}
|
}
|
||||||
if params \
|
if params \
|
||||||
and not compare_args_ipa(ansible_module, params, res_show):
|
and not compare_args_ipa(ansible_module, params, result):
|
||||||
changed = True
|
changed = True
|
||||||
if not ansible_module.check_mode:
|
if not ansible_module.check_mode:
|
||||||
try:
|
try:
|
||||||
@@ -409,38 +408,36 @@ def main():
|
|||||||
except ipalib_errors.EmptyModlist:
|
except ipalib_errors.EmptyModlist:
|
||||||
changed = False
|
changed = False
|
||||||
else:
|
else:
|
||||||
rawresult = ansible_module.ipa_command_no_name("config_show", {})
|
|
||||||
result = rawresult['result']
|
|
||||||
del result['dn']
|
del result['dn']
|
||||||
|
type_map = {"str": str, "int": int, "list": list, "bool": bool}
|
||||||
for key, value in result.items():
|
for key, value in result.items():
|
||||||
k = reverse_field_map.get(key, key)
|
k = reverse_field_map.get(key, key)
|
||||||
if ansible_module.argument_spec.get(k):
|
if ansible_module.argument_spec.get(k):
|
||||||
if k == 'ipaselinuxusermaporder':
|
arg_type = ansible_module.argument_spec[k]['type']
|
||||||
exit_args['ipaselinuxusermaporder'] = \
|
if k in (
|
||||||
result.get(key)[0].split('$')
|
'ipaselinuxusermaporder', 'domain_resolution_order'
|
||||||
elif k == 'domain_resolution_order':
|
):
|
||||||
exit_args['domain_resolution_order'] = \
|
exit_args[k] = result.get(key)[0].split('$')
|
||||||
result.get(key)[0].split('$')
|
elif k in (
|
||||||
elif k == 'usersearch':
|
'usersearch', 'groupsearch'
|
||||||
exit_args['usersearch'] = \
|
):
|
||||||
result.get(key)[0].split(',')
|
exit_args[k] = result.get(key)[0].split(',')
|
||||||
elif k == 'groupsearch':
|
elif isinstance(value, str) and arg_type == "list":
|
||||||
exit_args['groupsearch'] = \
|
|
||||||
result.get(key)[0].split(',')
|
|
||||||
elif isinstance(value, str) and \
|
|
||||||
ansible_module.argument_spec[k]['type'] == "list":
|
|
||||||
exit_args[k] = [value]
|
exit_args[k] = [value]
|
||||||
elif isinstance(value, list) and \
|
elif (
|
||||||
ansible_module.argument_spec[k]['type'] == "str":
|
isinstance(value, (tuple, list))
|
||||||
exit_args[k] = ",".join(value)
|
and arg_type in ("str", "int")
|
||||||
elif isinstance(value, list) and \
|
):
|
||||||
ansible_module.argument_spec[k]['type'] == "int":
|
exit_args[k] = type_map[arg_type](value[0])
|
||||||
exit_args[k] = ",".join(value)
|
elif (
|
||||||
elif isinstance(value, list) and \
|
isinstance(value, (tuple, list)) and arg_type == "bool"
|
||||||
ansible_module.argument_spec[k]['type'] == "bool":
|
):
|
||||||
exit_args[k] = (value[0] == "TRUE")
|
exit_args[k] = (value[0] == "TRUE")
|
||||||
else:
|
else:
|
||||||
exit_args[k] = value
|
if arg_type not in type_map:
|
||||||
|
raise ValueError(
|
||||||
|
"Unexpected attribute type: %s" % arg_type)
|
||||||
|
exit_args[k] = type_map[arg_type](value)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
ansible_module.exit_json(changed=changed, config=exit_args)
|
ansible_module.exit_json(changed=changed, config=exit_args)
|
||||||
|
|||||||
Reference in New Issue
Block a user