From 94efecaf67e671c002d8473a1cf269b600287095 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 21:03:54 +0100 Subject: [PATCH] [PR #6160/a49ad340 backport][stable-6] [make] Provide built command in the module output (#6186) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [make] Provide built command in the module output (#6160) It may happen operator wants to get the built command instead of all the parameters. This change injects a new entry in the dict output, showing what command way actually launched. This patch also takes the opportunity to add missing dots to some documentation lines. (cherry picked from commit a49ad340af86680440ec502af65f667e8bbb6ff9) Co-authored-by: Cédric Jeanneret <39397510+cjeanner@users.noreply.github.com> --- .../fragments/6160-add-command-make-output.yml | 2 ++ plugins/modules/make.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6160-add-command-make-output.yml diff --git a/changelogs/fragments/6160-add-command-make-output.yml b/changelogs/fragments/6160-add-command-make-output.yml new file mode 100644 index 0000000000..cf43107919 --- /dev/null +++ b/changelogs/fragments/6160-add-command-make-output.yml @@ -0,0 +1,2 @@ +minor_changes: + - make - add ``command`` return value to the module output (https://github.com/ansible-collections/community.general/pull/6160). diff --git a/plugins/modules/make.py b/plugins/modules/make.py index ec19b367c3..ebff6cfe11 100644 --- a/plugins/modules/make.py +++ b/plugins/modules/make.py @@ -89,6 +89,12 @@ chdir: - The value of the module parameter I(chdir). type: str returned: success +command: + description: + - The command built and executed by the module. + type: str + returned: success + version_added: 6.5.0 file: description: - The value of the module parameter I(file). @@ -96,22 +102,23 @@ file: returned: success jobs: description: - - The value of the module parameter I(jobs) + - The value of the module parameter I(jobs). type: int returned: success params: description: - - The value of the module parameter I(params) + - The value of the module parameter I(params). type: dict returned: success target: description: - - The value of the module parameter I(target) + - The value of the module parameter I(target). type: str returned: success ''' from ansible.module_utils.six import iteritems +from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils.basic import AnsibleModule @@ -218,6 +225,7 @@ def main(): chdir=module.params['chdir'], file=module.params['file'], jobs=module.params['jobs'], + command=' '.join([shlex_quote(part) for part in base_command]), )