mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-01 09:56:18 +00:00
[PR #11645/a09e879f backport][stable-11] xfconf: fix boolean return values (#11649)
xfconf: fix boolean return values (#11645)
* xfconf: fix boolean return values
* add changelog frag
(cherry picked from commit a09e879ff2)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
a742525c89
commit
4bd1bb8c2a
3 changed files with 43 additions and 4 deletions
|
|
@ -176,6 +176,8 @@ version:
|
|||
version_added: 10.2.0
|
||||
"""
|
||||
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
|
||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner, get_xfconf_version
|
||||
|
||||
|
|
@ -238,9 +240,6 @@ class XFConfProperty(StateModuleHelper):
|
|||
self.vars.value = None
|
||||
|
||||
def state_present(self):
|
||||
# stringify all values - in the CLI they will all be happy strings anyway
|
||||
# and by doing this here the rest of the code can be agnostic to it
|
||||
self.vars.value = [str(v) for v in self.vars.value]
|
||||
value_type = self.vars.value_type
|
||||
|
||||
values_len = len(self.vars.value)
|
||||
|
|
@ -253,6 +252,14 @@ class XFConfProperty(StateModuleHelper):
|
|||
# or complain if lists' lengths are different
|
||||
self.do_raise('Number of elements in "value" and "value_type" must be the same')
|
||||
|
||||
# stringify all values - in the CLI they will all be happy strings anyway
|
||||
# and by doing this here the rest of the code can be agnostic to it
|
||||
# bool values are normalized to 'true'/'false' to match xfconf-query output format
|
||||
self.vars.value = [
|
||||
("true" if boolean(v) else "false") if vt == "bool" else str(v)
|
||||
for v, vt in zip(self.vars.value, value_type)
|
||||
]
|
||||
|
||||
# calculates if it is an array
|
||||
self.vars.is_array = \
|
||||
bool(self.vars.force_array) or \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue