mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-29 02:44:43 +00:00
Fix handling of boolean values for FreeIPA 4.9.10+
FreeIPA 4.9.10+ and 4.10 use proper mapping for boolean values, and only searching for "TRUE" does not work anymore. This patch fix ipadnszone plugin and IPAParamMapping class handling of boolean values.
This commit is contained in:
@@ -845,7 +845,10 @@ else:
|
|||||||
# Check if param_name is actually a param
|
# Check if param_name is actually a param
|
||||||
if param_name in self.ansible_module.params:
|
if param_name in self.ansible_module.params:
|
||||||
value = self.ansible_module.params_get(param_name)
|
value = self.ansible_module.params_get(param_name)
|
||||||
if isinstance(value, bool):
|
if (
|
||||||
|
self.ansible_module.ipa_check_version("<", "4.9.10")
|
||||||
|
and isinstance(value, bool)
|
||||||
|
):
|
||||||
value = "TRUE" if value else "FALSE"
|
value = "TRUE" if value else "FALSE"
|
||||||
|
|
||||||
# Since param wasn't a param check if it's a method name
|
# Since param wasn't a param check if it's a method name
|
||||||
|
|||||||
@@ -441,7 +441,11 @@ def main():
|
|||||||
elif (
|
elif (
|
||||||
isinstance(value, (tuple, list)) and arg_type == "bool"
|
isinstance(value, (tuple, list)) and arg_type == "bool"
|
||||||
):
|
):
|
||||||
exit_args[k] = (value[0] == "TRUE")
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
exit_args[k] = (str(value[0]).upper() == "TRUE")
|
||||||
else:
|
else:
|
||||||
if arg_type not in type_map:
|
if arg_type not in type_map:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|||||||
@@ -344,7 +344,13 @@ def main():
|
|||||||
|
|
||||||
if state in ['enabled', 'disabled']:
|
if state in ['enabled', 'disabled']:
|
||||||
if existing_resource is not None:
|
if existing_resource is not None:
|
||||||
is_enabled = existing_resource["idnszoneactive"][0]
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
is_enabled = (
|
||||||
|
str(existing_resource["idnszoneactive"][0]).upper()
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
ansible_module.fail_json(
|
ansible_module.fail_json(
|
||||||
msg="dnsforwardzone '%s' not found." % (name))
|
msg="dnsforwardzone '%s' not found." % (name))
|
||||||
|
|||||||
@@ -418,7 +418,11 @@ class DNSZoneModule(IPAAnsibleModule):
|
|||||||
is_zone_active = False
|
is_zone_active = False
|
||||||
else:
|
else:
|
||||||
zone = response["result"]
|
zone = response["result"]
|
||||||
is_zone_active = "TRUE" in zone.get("idnszoneactive")
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for boolean vaalues.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
is_zone_active = (
|
||||||
|
str(zone.get("idnszoneactive")[0]).upper() == "TRUE"
|
||||||
|
)
|
||||||
|
|
||||||
return zone, is_zone_active
|
return zone, is_zone_active
|
||||||
|
|
||||||
|
|||||||
@@ -472,18 +472,26 @@ def main():
|
|||||||
# hbacrule_enable is not failing on an enabled hbacrule
|
# hbacrule_enable is not failing on an enabled hbacrule
|
||||||
# Therefore it is needed to have a look at the ipaenabledflag
|
# Therefore it is needed to have a look at the ipaenabledflag
|
||||||
# in res_find.
|
# in res_find.
|
||||||
if "ipaenabledflag" not in res_find or \
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
res_find["ipaenabledflag"][0] != "TRUE":
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
enabled_flag = str(res_find.get("ipaenabledflag", [False])[0])
|
||||||
|
if enabled_flag.upper() != "TRUE":
|
||||||
commands.append([name, "hbacrule_enable", {}])
|
commands.append([name, "hbacrule_enable", {}])
|
||||||
|
|
||||||
elif state == "disabled":
|
elif state == "disabled":
|
||||||
if res_find is None:
|
if res_find is None:
|
||||||
ansible_module.fail_json(msg="No hbacrule '%s'" % name)
|
ansible_module.fail_json(msg="No hbacrule '%s'" % name)
|
||||||
# hbacrule_disable is not failing on an disabled hbacrule
|
# hbacrule_disable is not failing on an enabled hbacrule
|
||||||
# Therefore it is needed to have a look at the ipaenabledflag
|
# Therefore it is needed to have a look at the ipaenabledflag
|
||||||
# in res_find.
|
# in res_find.
|
||||||
if "ipaenabledflag" not in res_find or \
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
res_find["ipaenabledflag"][0] != "FALSE":
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
enabled_flag = str(res_find.get("ipaenabledflag", [False])[0])
|
||||||
|
if enabled_flag.upper() != "FALSE":
|
||||||
commands.append([name, "hbacrule_disable", {}])
|
commands.append([name, "hbacrule_disable", {}])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -656,8 +656,12 @@ def main():
|
|||||||
# sudorule_enable is not failing on an enabled sudorule
|
# sudorule_enable is not failing on an enabled sudorule
|
||||||
# Therefore it is needed to have a look at the ipaenabledflag
|
# Therefore it is needed to have a look at the ipaenabledflag
|
||||||
# in res_find.
|
# in res_find.
|
||||||
if "ipaenabledflag" not in res_find or \
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
res_find["ipaenabledflag"][0] != "TRUE":
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
enabled_flag = str(res_find.get("ipaenabledflag", [False])[0])
|
||||||
|
if enabled_flag.upper() != "TRUE":
|
||||||
commands.append([name, "sudorule_enable", {}])
|
commands.append([name, "sudorule_enable", {}])
|
||||||
|
|
||||||
elif state == "disabled":
|
elif state == "disabled":
|
||||||
@@ -666,8 +670,12 @@ def main():
|
|||||||
# sudorule_disable is not failing on an disabled sudorule
|
# sudorule_disable is not failing on an disabled sudorule
|
||||||
# Therefore it is needed to have a look at the ipaenabledflag
|
# Therefore it is needed to have a look at the ipaenabledflag
|
||||||
# in res_find.
|
# in res_find.
|
||||||
if "ipaenabledflag" not in res_find or \
|
# FreeIPA 4.9.10+ and 4.10 use proper mapping for
|
||||||
res_find["ipaenabledflag"][0] != "FALSE":
|
# boolean values, so we need to convert it to str
|
||||||
|
# for comparison.
|
||||||
|
# See: https://github.com/freeipa/freeipa/pull/6294
|
||||||
|
enabled_flag = str(res_find.get("ipaenabledflag", [False])[0])
|
||||||
|
if enabled_flag.upper() != "FALSE":
|
||||||
commands.append([name, "sudorule_disable", {}])
|
commands.append([name, "sudorule_disable", {}])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user