Skip to content

Commit

Permalink
service: Refactor 'delete_continue' to match other modules.
Browse files Browse the repository at this point in the history
The parameter 'delete_continue' must be supported by several modules,
and this patch makes ipaservice module use the same structures as other
modules.
  • Loading branch information
rjeffman committed Feb 8, 2022
1 parent e2c2823 commit 1c8e98c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +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_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
`continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `no` (bool) | no
`delete_continue` \| `continue` | Continuous mode: don't stop on errors. Valid only if `state` is `absent`. Default: `no` (bool) | no
`smb` | Service is an SMB service. If set, `cifs/` will be prefixed to the service name if needed. | no
`netbiosname` | NETBIOS name for the SMB service. Only with `smb: yes`. | no
`action` | Work on service or member level. It can be on of `member` or `service` and defaults to `service`. | no
Expand Down
17 changes: 3 additions & 14 deletions plugins/modules/ipaservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
description: Manage FreeIPA service
extends_documentation_fragment:
- ipamodule_base_docs
- ipamodule_arguments.delete_continue
options:
name:
description: The service to manage
Expand Down Expand Up @@ -142,12 +143,6 @@
required: false
type: list
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:
description: Work on service or member level
default: service
Expand Down Expand Up @@ -308,7 +303,7 @@ def check_parameters(module, state, action, names):
module.fail_json(msg="Only one service can be added at a time.")

if action == 'service':
invalid = ['delete_continue']
invalid = []

if (
not module.params_get('smb')
Expand All @@ -317,21 +312,16 @@ def check_parameters(module, state, action, names):
module.fail_json(
msg="Argument 'netbiosname' can not be used without "
"SMB service.")
else:
invalid.append('delete_continue')

elif state == 'absent':
if len(names) < 1:
module.fail_json(msg="No name given.")

if action == "service":
invalid.extend(invalid_not_member)
else:
invalid.extend('delete_continue')

elif state == 'disabled':
invalid.extend(invalid_not_member)
invalid.append('delete_continue')
if action != "service":
module.fail_json(
msg="Invalid action '%s' for state '%s'" % (action, state))
Expand Down Expand Up @@ -392,8 +382,6 @@ def init_ansible_module():
allow_retrieve_keytab_hostgroup=dict(
type="list", required=False,
aliases=['ipaallowedtoperform_read_keys_hostgroup']),
delete_continue=dict(type="bool", required=False,
aliases=['continue']),
# action
action=dict(type="str", default="service",
choices=["member", "service"]),
Expand All @@ -402,6 +390,7 @@ def init_ansible_module():
choices=["present", "absent", "disabled"]),
),
supports_check_mode=True,
ipa_arguments=["delete_continue"],
)

ansible_module._ansible_debug = True
Expand Down

0 comments on commit 1c8e98c

Please sign in to comment.