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:
parent
0df41241dd
commit
927356dad3
2 changed files with 7 additions and 2 deletions
2
changelogs/fragments/3648-mh-cmd-publish-cmd.yaml
Normal file
2
changelogs/fragments/3648-mh-cmd-publish-cmd.yaml
Normal 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).
|
|
@ -158,8 +158,9 @@ class CmdMixin(object):
|
||||||
publish_rc=True,
|
publish_rc=True,
|
||||||
publish_out=True,
|
publish_out=True,
|
||||||
publish_err=True,
|
publish_err=True,
|
||||||
|
publish_cmd=True,
|
||||||
*args, **kwargs):
|
*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 = dict(self.run_command_fixed_options)
|
||||||
options['check_rc'] = options.get('check_rc', self.check_rc)
|
options['check_rc'] = options.get('check_rc', self.check_rc)
|
||||||
options.update(kwargs)
|
options.update(kwargs)
|
||||||
|
@ -171,13 +172,15 @@ class CmdMixin(object):
|
||||||
})
|
})
|
||||||
self.update_output(force_lang=self.force_lang)
|
self.update_output(force_lang=self.force_lang)
|
||||||
options['environ_update'] = env_update
|
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:
|
if publish_rc:
|
||||||
self.update_output(rc=rc)
|
self.update_output(rc=rc)
|
||||||
if publish_out:
|
if publish_out:
|
||||||
self.update_output(stdout=out)
|
self.update_output(stdout=out)
|
||||||
if publish_err:
|
if publish_err:
|
||||||
self.update_output(stderr=err)
|
self.update_output(stderr=err)
|
||||||
|
if publish_cmd:
|
||||||
|
self.update_output(cmd_args=cmd_args)
|
||||||
if process_output is None:
|
if process_output is None:
|
||||||
_process = self.process_command_output
|
_process = self.process_command_output
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue