Skip to content
Snippets Groups Projects
Commit 561cd4fb authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

Add support for FreeIPA API service_del `continue` option.

parent 4ad10336
No related branches found
No related tags found
No related merge requests found
...@@ -310,6 +310,7 @@ Variable | Description | Required ...@@ -310,6 +310,7 @@ Variable | Description | Required
`allow_retrieve_keytab_group` \| `ipaallowedtoperform_read_keys_group` | Groups allowed to retrieve a keytab of this host. | no `allow_retrieve_keytab_group` \| `ipaallowedtoperform_read_keys_group` | Groups allowed to retrieve a keytab of this host. | no
`allow_retrieve_keytab_host` \| `ipaallowedtoperform_read_keys_host` | Hosts allowed to retrieve a keytab from of host. | no `allow_retrieve_keytab_host` \| `ipaallowedtoperform_read_keys_host` | Hosts allowed to retrieve a keytab from of host. | no
`allow_retrieve_keytab_hostgroup` \| `ipaallowedtoperform_read_keys_hostgroup` | Host groups allowed to retrieve a keytab of this host. | no `allow_retrieve_keytab_hostgroup` \| `ipaallowedtoperform_read_keys_hostgroup` | Host groups allowed to retrieve a keytab of this host. | no
`continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `no` (bool) | no
`action` | Work on service or member level. It can be on of `member` or `service` and defaults to `service`. | no `action` | Work on service or member level. It can be on of `member` or `service` and defaults to `service`. | no
`state` | The state to ensure. It can be one of `present`, `absent`, or `disabled`, default: `present`. | no `state` | The state to ensure. It can be one of `present`, `absent`, or `disabled`, default: `present`. | no
......
...@@ -135,6 +135,12 @@ options: ...@@ -135,6 +135,12 @@ options:
required: false required: false
type: list type: list
aliases: ["ipaallowedtoperform_read_keys_hostgroup"] aliases: ["ipaallowedtoperform_read_keys_hostgroup"]
continue:
description:
Continuous mode. Don't stop on errors. Valid only if `state` is `absent`.
required: false
default: True
type: bool
action: action:
description: Work on service or member level description: Work on service or member level
default: service default: service
...@@ -284,7 +290,9 @@ def check_parameters(module, state, action, names, parameters): ...@@ -284,7 +290,9 @@ def check_parameters(module, state, action, names, parameters):
module.fail_json(msg="Only one service can be added at a time.") module.fail_json(msg="Only one service can be added at a time.")
if action == 'service': if action == 'service':
invalid = [] invalid = ['delete_continue']
else:
invalid.append('delete_continue')
elif state == 'absent': elif state == 'absent':
if len(names) < 1: if len(names) < 1:
...@@ -292,9 +300,12 @@ def check_parameters(module, state, action, names, parameters): ...@@ -292,9 +300,12 @@ def check_parameters(module, state, action, names, parameters):
if action == "service": if action == "service":
invalid.extend(invalid_not_member) invalid.extend(invalid_not_member)
else:
invalid.extend('delete_continue')
elif state == 'disabled': elif state == 'disabled':
invalid.extend(invalid_not_member) invalid.extend(invalid_not_member)
invalid.append('delete_continue')
if action != "service": if action != "service":
module.fail_json( module.fail_json(
msg="Invalid action '%s' for state '%s'" % (action, state)) msg="Invalid action '%s' for state '%s'" % (action, state))
...@@ -303,7 +314,7 @@ def check_parameters(module, state, action, names, parameters): ...@@ -303,7 +314,7 @@ def check_parameters(module, state, action, names, parameters):
module.fail_json(msg="Invalid state '%s'" % (state)) module.fail_json(msg="Invalid state '%s'" % (state))
for _invalid in invalid: for _invalid in invalid:
if parameters[_invalid] is not None: if _invalid in parameters and parameters[_invalid] is not None:
module.fail_json( module.fail_json(
msg="Argument '%s' can not be used with state '%s', " msg="Argument '%s' can not be used with state '%s', "
"action '%s'" % (_invalid, state, action)) "action '%s'" % (_invalid, state, action))
...@@ -360,6 +371,8 @@ def init_ansible_module(): ...@@ -360,6 +371,8 @@ def init_ansible_module():
allow_retrieve_keytab_hostgroup=dict( allow_retrieve_keytab_hostgroup=dict(
type="list", required=False, type="list", required=False,
aliases=['ipaallowedtoperform_read_keys_hostgroup']), aliases=['ipaallowedtoperform_read_keys_hostgroup']),
delete_continue=dict(type="bool", required=False,
aliases=['continue']),
# action # action
action=dict(type="str", default="service", action=dict(type="str", default="service",
choices=["member", "service"]), choices=["member", "service"]),
...@@ -417,6 +430,7 @@ def main(): ...@@ -417,6 +430,7 @@ def main():
ansible_module, "allow_create_keytab_host") ansible_module, "allow_create_keytab_host")
allow_retrieve_keytab_hostgroup = module_params_get( allow_retrieve_keytab_hostgroup = module_params_get(
ansible_module, "allow_retrieve_keytab_hostgroup") ansible_module, "allow_retrieve_keytab_hostgroup")
delete_continue = module_params_get(ansible_module, "delete_continue")
# action # action
action = module_params_get(ansible_module, "action") action = module_params_get(ansible_module, "action")
...@@ -699,7 +713,8 @@ def main(): ...@@ -699,7 +713,8 @@ def main():
elif state == "absent": elif state == "absent":
if action == "service": if action == "service":
if res_find is not None: if res_find is not None:
commands.append([name, 'service_del', {}]) args = {'continue': True if delete_continue else False}
commands.append([name, 'service_del', args])
elif action == "member": elif action == "member":
if res_find is None: if res_find is None:
......
...@@ -515,6 +515,32 @@ ...@@ -515,6 +515,32 @@
register: result register: result
failed_when: result.changed failed_when: result.changed
- name: Ensure services are absent.
ipaservice:
ipaadmin_password: SomeADMINpassword
name:
- "HTTP/{{ svc_fqdn }}"
- HTTP/www.ansible.com
- HTTP/svc.ihavenodns.info
- HTTP/no.idontexist.local
continue: yes
state: absent
register: result
failed_when: not result.changed
- name: Ensure services are absent.
ipaservice:
ipaadmin_password: SomeADMINpassword
name:
- "HTTP/{{ svc_fqdn }}"
- HTTP/www.ansible.com
- HTTP/svc.ihavenodns.info
- HTTP/no.idontexist.local
continue: yes
state: absent
register: result
failed_when: result.changed
# cleanup # cleanup
- name: Ensure services are absent. - name: Ensure services are absent.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment