From de2feb2567b2f05530cf014ef07be630a72729ab Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 18 May 2021 06:36:02 +0200 Subject: [PATCH] ModuleHelper - cmd params now taken from self.vars instead of self.module.params (#2517) (#2549) * cmd params now taken from self.vars instead of self.module.params * added changelog fragment * Update changelogs/fragments/2517-cmd-params-from-vars.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit d24fc92466cc48d8dc436b80a2613635061b8f07) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/2517-cmd-params-from-vars.yml | 2 ++ plugins/module_utils/mh/mixins/cmd.py | 6 +++--- plugins/modules/system/xfconf.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/2517-cmd-params-from-vars.yml diff --git a/changelogs/fragments/2517-cmd-params-from-vars.yml b/changelogs/fragments/2517-cmd-params-from-vars.yml new file mode 100644 index 0000000000..95a2f7165d --- /dev/null +++ b/changelogs/fragments/2517-cmd-params-from-vars.yml @@ -0,0 +1,2 @@ +minor_changes: + - cmd (Module Helper) module utils - ``CmdMixin`` now pulls the value for ``run_command()`` params from ``self.vars``, as opposed to previously retrieving those from ``self.module.params`` (https://github.com/ansible-collections/community.general/pull/2517). diff --git a/plugins/module_utils/mh/mixins/cmd.py b/plugins/module_utils/mh/mixins/cmd.py index fc66638f69..eb7cc698cc 100644 --- a/plugins/module_utils/mh/mixins/cmd.py +++ b/plugins/module_utils/mh/mixins/cmd.py @@ -120,7 +120,7 @@ class CmdMixin(object): cmd_args[0] = self.module.get_bin_path(cmd_args[0], required=True) except ValueError: pass - param_list = params if params else self.module.params.keys() + param_list = params if params else self.vars.keys() for param in param_list: if isinstance(param, dict): @@ -131,9 +131,9 @@ class CmdMixin(object): fmt = find_format(_param) value = param[_param] elif isinstance(param, str): - if param in self.module.argument_spec: + if param in self.vars.keys(): fmt = find_format(param) - value = self.module.params[param] + value = self.vars[param] elif param in extra_params: fmt = find_format(param) value = extra_params[param] diff --git a/plugins/modules/system/xfconf.py b/plugins/modules/system/xfconf.py index f2975df050..dc560e7775 100644 --- a/plugins/modules/system/xfconf.py +++ b/plugins/modules/system/xfconf.py @@ -258,7 +258,7 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper): params = ['channel', 'property', {'create': True}] if self.vars.is_array: - params.append({'is_array': True}) + params.append('is_array') params.append({'values_and_types': (self.vars.value, value_type)}) if not self.module.check_mode: