summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/general/plugins/modules/gconftool2.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/general/plugins/modules/gconftool2.py
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/general/plugins/modules/gconftool2.py')
-rw-r--r--ansible_collections/community/general/plugins/modules/gconftool2.py52
1 files changed, 31 insertions, 21 deletions
diff --git a/ansible_collections/community/general/plugins/modules/gconftool2.py b/ansible_collections/community/general/plugins/modules/gconftool2.py
index 949e92b30..a40304a16 100644
--- a/ansible_collections/community/general/plugins/modules/gconftool2.py
+++ b/ansible_collections/community/general/plugins/modules/gconftool2.py
@@ -35,20 +35,20 @@ options:
type: str
description:
- Preference keys typically have simple values such as strings,
- integers, or lists of strings and integers. This is ignored if the state
- is "get". See man gconftool-2(1).
+ integers, or lists of strings and integers.
+ This is ignored unless O(state=present). See man gconftool-2(1).
value_type:
type: str
description:
- - The type of value being set. This is ignored if the state is "get".
+ - The type of value being set.
+ This is ignored unless O(state=present). See man gconftool-2(1).
choices: [ bool, float, int, string ]
state:
type: str
description:
- The action to take upon the key/value.
- - State C(get) is deprecated and will be removed in community.general 8.0.0. Please use the module M(community.general.gconftool2_info) instead.
required: true
- choices: [ absent, get, present ]
+ choices: [ absent, present ]
config_source:
type: str
description:
@@ -56,8 +56,8 @@ options:
See man gconftool-2(1).
direct:
description:
- - Access the config database directly, bypassing server. If direct is
- specified then the config_source must be specified as well.
+ - Access the config database directly, bypassing server. If O(direct) is
+ specified then the O(config_source) must be specified as well.
See man gconftool-2(1).
type: bool
default: false
@@ -73,17 +73,26 @@ EXAMPLES = """
RETURN = '''
key:
- description: The key specified in the module parameters
+ description: The key specified in the module parameters.
returned: success
type: str
sample: /desktop/gnome/interface/font_name
value_type:
- description: The type of the value that was changed
+ description: The type of the value that was changed.
returned: success
type: str
sample: string
value:
- description: The value of the preference key after executing the module
+ description:
+ - The value of the preference key after executing the module or V(null) if key is removed.
+ - From community.general 7.0.0 onwards it returns V(null) for a non-existent O(key), and returned V("") before that.
+ returned: success
+ type: str
+ sample: "Serif 12"
+ previous_value:
+ description:
+ - The value of the preference key before executing the module.
+ - From community.general 7.0.0 onwards it returns V(null) for a non-existent O(key), and returned V("") before that.
returned: success
type: str
sample: "Serif 12"
@@ -95,7 +104,6 @@ from ansible_collections.community.general.plugins.module_utils.gconftool2 impor
class GConftool(StateModuleHelper):
- change_params = ('value', )
diff_params = ('value', )
output_params = ('key', 'value_type')
facts_params = ('key', 'value_type')
@@ -105,13 +113,12 @@ class GConftool(StateModuleHelper):
key=dict(type='str', required=True, no_log=False),
value_type=dict(type='str', choices=['bool', 'float', 'int', 'string']),
value=dict(type='str'),
- state=dict(type='str', required=True, choices=['absent', 'get', 'present']),
+ state=dict(type='str', required=True, choices=['absent', 'present']),
direct=dict(type='bool', default=False),
config_source=dict(type='str'),
),
required_if=[
('state', 'present', ['value', 'value_type']),
- ('state', 'absent', ['value']),
('direct', True, ['config_source']),
],
supports_check_mode=True,
@@ -125,6 +132,7 @@ class GConftool(StateModuleHelper):
self.vars.set('previous_value', self._get(), fact=True)
self.vars.set('value_type', self.vars.value_type)
+ self.vars.set('_value', self.vars.previous_value, output=False, change=True)
self.vars.set_meta('value', initial_value=self.vars.previous_value)
self.vars.set('playbook_value', self.vars.value, fact=True)
@@ -132,27 +140,29 @@ class GConftool(StateModuleHelper):
def process(rc, out, err):
if err and fail_on_err:
self.ansible.fail_json(msg='gconftool-2 failed with error: %s' % (str(err)))
- self.vars.value = out.rstrip()
+ out = out.rstrip()
+ self.vars.value = None if out == "" else out
return self.vars.value
return process
def _get(self):
return self.runner("state key", output_process=self._make_process(False)).run(state="get")
- def state_get(self):
- self.deprecate(
- msg="State 'get' is deprecated. Please use the module community.general.gconftool2_info instead",
- version="8.0.0", collection_name="community.general"
- )
-
def state_absent(self):
with self.runner("state key", output_process=self._make_process(False)) as ctx:
ctx.run()
+ if self.verbosity >= 4:
+ self.vars.run_info = ctx.run_info
self.vars.set('new_value', None, fact=True)
+ self.vars._value = None
def state_present(self):
with self.runner("direct config_source value_type state key value", output_process=self._make_process(True)) as ctx:
- self.vars.set('new_value', ctx.run(), fact=True)
+ ctx.run()
+ if self.verbosity >= 4:
+ self.vars.run_info = ctx.run_info
+ self.vars.set('new_value', self._get(), fact=True)
+ self.vars._value = self.vars.new_value
def main():