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

ipapermission: add version check for bind type 'self'

FreeIPA 4.8.7 has introduced bind type 'self' as a valid value, and
this PR adds checks so the module fails early if the value is used
with an unsupported version.

Tests and documentation have been updated to reflect the changes.
parent 2aaabc77
No related branches found
No related tags found
No related merge requests found
...@@ -141,7 +141,7 @@ Variable | Description | Required ...@@ -141,7 +141,7 @@ Variable | Description | Required
`name` \| `cn` | The permission name string. | yes `name` \| `cn` | The permission name string. | yes
`right` \| `ipapermright` | Rights to grant. It can be a list of one or more of `read`, `search`, `compare`, `write`, `add`, `delete`, and `all` default: `all` | no `right` \| `ipapermright` | Rights to grant. It can be a list of one or more of `read`, `search`, `compare`, `write`, `add`, `delete`, and `all` default: `all` | no
`attrs` | All attributes to which the permission applies | no `attrs` | All attributes to which the permission applies | no
`bindtype` \| `ipapermbindruletype` | Bind rule type. It can be one of `permission`, `all`, `self`, or `anonymous` defaults to `permission` for new permissions.| no `bindtype` \| `ipapermbindruletype` | Bind rule type. It can be one of `permission`, `all`, `self`, or `anonymous` defaults to `permission` for new permissions. Bind rule type `self` can only be used on IPA versions 4.8.7 or up.| no
`subtree` \| `ipapermlocation` | Subtree to apply permissions to | no `subtree` \| `ipapermlocation` | Subtree to apply permissions to | no
`filter` \| `extratargetfilter` | Extra target filter | no `filter` \| `extratargetfilter` | Extra target filter | no
`rawfilter` \| `ipapermtargetfilter` | All target filters | no `rawfilter` \| `ipapermtargetfilter` | All target filters | no
......
...@@ -152,7 +152,8 @@ RETURN = """ ...@@ -152,7 +152,8 @@ RETURN = """
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ansible_freeipa_module import \ from ansible.module_utils.ansible_freeipa_module import \
temp_kinit, temp_kdestroy, valid_creds, api_connect, api_command, \ temp_kinit, temp_kdestroy, valid_creds, api_connect, api_command, \
compare_args_ipa, module_params_get, gen_add_del_lists compare_args_ipa, module_params_get, gen_add_del_lists, \
api_check_ipa_version
import six import six
if six.PY3: if six.PY3:
...@@ -336,6 +337,10 @@ def main(): ...@@ -336,6 +337,10 @@ def main():
msg="Argument '%s' can not be used with action " msg="Argument '%s' can not be used with action "
"'%s' and state '%s'" % (x, action, state)) "'%s' and state '%s'" % (x, action, state))
if bindtype == "self" and api_check_ipa_version("<", "4.8.7"):
ansible_module.fail_json(
msg="Bindtype 'self' is not supported by your IPA version.")
# Init # Init
changed = False changed = False
......
...@@ -4,13 +4,17 @@ ...@@ -4,13 +4,17 @@
become: true become: true
tasks: tasks:
- include_tasks: ../env_freeipa_facts.yml
# CLEANUP TEST ITEMS # CLEANUP TEST ITEMS
- name: Ensure permission perm-test-1 is absent - name: Ensure permission perm-test-1 is absent
ipapermission: ipapermission:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
name: perm-test-1 name:
- perm-test-1
- perm-test-bindtype-test
- perm-test-renamed
state: absent state: absent
# TESTS # TESTS
...@@ -99,16 +103,35 @@ ...@@ -99,16 +103,35 @@
register: result register: result
failed_when: result.changed or result.failed failed_when: result.changed or result.failed
# CLEANUP TEST ITEMS - name: Ensure permission with bindtype 'self' is present, if IPA version >= 4.8.7
ipapermission:
ipaadmin_password: SomeADMINpassword
name: perm-test-bindtype-test
bindtype: self
object_type: host
right: all
when: ipa_version is version('4.8.7', '>=')
register: result
failed_when: not result.changed or result.failed
- name: Ensure permission perm-test-1 is absent - name: Fail to set permission perm-test-renamed bindtype to 'self', if IPA version < 4.8.7
ipapermission: ipapermission:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
name: perm-test-1 name: perm-test-bindtype-test
state: absent bindtype: self
object_type: host
right: all
when: ipa_version is version('4.8.7', '<')
register: result
failed_when: not result.failed or "Bindtype 'self' is not supported by your IPA version." not in result.msg
- name: Ensure permission perm-test-renamed is absent # CLEANUP TEST ITEMS
- name: Ensure permission perm-test-1 is absent
ipapermission: ipapermission:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
name: perm-test-renamed name:
- perm-test-1
- perm-test-bindtype-test
- perm-test-renamed
state: absent state: absent
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment