From 23e07a9a17d76ed469ed03805d645503f27f7fde Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Wed, 27 Apr 2022 11:20:55 -0300 Subject: [PATCH 1/2] ipaautomountmap: Force setting automountmapname in IPA API calls. The usage of 'automountmapname' is required in all automount map IPA API calls, and this change ensures that the value is always set as an argument. --- plugins/modules/ipaautomountmap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/modules/ipaautomountmap.py b/plugins/modules/ipaautomountmap.py index 9cca0a98..8f990d24 100644 --- a/plugins/modules/ipaautomountmap.py +++ b/plugins/modules/ipaautomountmap.py @@ -123,9 +123,10 @@ class AutomountMap(IPAAnsibleModule): self.params_fail_used_invalid(invalid, state) def get_args(self, mapname, desc): # pylint: disable=no-self-use - _args = {} - if mapname: - _args["automountmapname"] = mapname + # automountmapname is required for all automountmap operations. + if not mapname: + self.fail_json(msg="automountmapname cannot be None or empty.") + _args = {"automountmapname": mapname} # An empty string is valid and will clear the attribute. if desc is not None: _args["description"] = desc From 1a31f62a6f63689ea2f35775cc1d16c446078b96 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Wed, 27 Apr 2022 11:26:32 -0300 Subject: [PATCH 2/2] ipaautomountmap: Fix error messages for invalid 'name' sizes. This patch fixes the error messages when an invalid number of 'mapname' are provided for states 'present' or 'absent'. --- plugins/modules/ipaautomountmap.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/modules/ipaautomountmap.py b/plugins/modules/ipaautomountmap.py index 8f990d24..67857c62 100644 --- a/plugins/modules/ipaautomountmap.py +++ b/plugins/modules/ipaautomountmap.py @@ -112,12 +112,12 @@ class AutomountMap(IPAAnsibleModule): state = self.params_get("state") if state == "present": if len(name) != 1: - self.fail_json(msg="Exactly one name must be provided \ - for state=present.") + self.fail_json(msg="Exactly one name must be provided for" + " 'state: present'.") if state == "absent": if len(name) == 0: - self.fail_json(msg="Argument 'map_type' can not be used with " - "state 'absent'") + self.fail_json(msg="At least one 'name' must be provided for" + " 'state: absent'") invalid = ["desc"] self.params_fail_used_invalid(invalid, state)