Skip to content
Snippets Groups Projects
Unverified Commit 3d6bf871 authored by Thomas Woerner's avatar Thomas Woerner Committed by GitHub
Browse files

Merge pull request #637 from rjeffman/ipaconfig_missing_params

config: Fix data returned from module.
parents 2da03cb8 87de471d
No related branches found
No related tags found
No related merge requests found
...@@ -252,7 +252,7 @@ from ansible.module_utils.ansible_freeipa_module import \ ...@@ -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(): ...@@ -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(): ...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment