gconftool2: refactored to use ModuleHelper + CmdRunner (#5545)

* gconftool2: refactored to use ModuleHelper + CmdRunner

* add changelog fragment

* removed old code commented out
This commit is contained in:
Alexei Znamensky 2022-11-16 09:02:45 +13:00 committed by GitHub
parent 6a6bbb6577
commit 6c7e9116e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 186 additions and 142 deletions

View file

@ -6,7 +6,14 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt
from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt
_state_map = {
"present": "--set",
"absent": "--unset",
"get": "--get",
}
def gconftool2_runner(module, **kwargs):
@ -14,14 +21,12 @@ def gconftool2_runner(module, **kwargs):
module,
command='gconftool-2',
arg_formats=dict(
key=fmt.as_list(),
value_type=fmt.as_opt_val("--type"),
value=fmt.as_list(),
direct=fmt.as_bool("--direct"),
config_source=fmt.as_opt_val("--config-source"),
get=fmt.as_bool("--get"),
set_arg=fmt.as_bool("--set"),
unset=fmt.as_bool("--unset"),
state=cmd_runner_fmt.as_map(_state_map),
key=cmd_runner_fmt.as_list(),
value_type=cmd_runner_fmt.as_opt_val("--type"),
value=cmd_runner_fmt.as_list(),
direct=cmd_runner_fmt.as_bool("--direct"),
config_source=cmd_runner_fmt.as_opt_val("--config-source"),
),
**kwargs
)