1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

mh/mixins/cmd - added publish_cmd parameter to CmdModuleHelper.run_command() (#3648)

* added publish_cmd parameter to CmdModuleHelper.run_command()

* added changelog fragment

* Update plugins/module_utils/mh/mixins/cmd.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2021-11-01 08:35:21 +13:00 committed by GitHub
parent 0df41241dd
commit 927356dad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- module_helper module utils - added feature flag parameter to ``CmdMixin`` to control whether ``cmd_args`` is automatically added to the module output (https://github.com/ansible-collections/community.general/pull/3648).

View file

@ -158,8 +158,9 @@ class CmdMixin(object):
publish_rc=True,
publish_out=True,
publish_err=True,
publish_cmd=True,
*args, **kwargs):
self.vars.cmd_args = self._calculate_args(extra_params, params)
cmd_args = self._calculate_args(extra_params, params)
options = dict(self.run_command_fixed_options)
options['check_rc'] = options.get('check_rc', self.check_rc)
options.update(kwargs)
@ -171,13 +172,15 @@ class CmdMixin(object):
})
self.update_output(force_lang=self.force_lang)
options['environ_update'] = env_update
rc, out, err = self.module.run_command(self.vars.cmd_args, *args, **options)
rc, out, err = self.module.run_command(cmd_args, *args, **options)
if publish_rc:
self.update_output(rc=rc)
if publish_out:
self.update_output(stdout=out)
if publish_err:
self.update_output(stderr=err)
if publish_cmd:
self.update_output(cmd_args=cmd_args)
if process_output is None:
_process = self.process_command_output
else: