From 5707fc1b33ecfbef936ea9f06a141f342bcfa6e9 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 06:29:27 +0200 Subject: [PATCH] [PR #7180/9021e741 backport][stable-6] community.general.make: (#7217) * community.general.make: (#7180) * community.general.make: allows parameters without value closes #7178 * add changelog fragment for community.general.make * correction: v != none -> v is not None * update fragment changelog as per developer request * add an example * document the modification * update example with comments as per maintainer request (cherry picked from commit 9021e7416d66d3853c4be655b2d54a13f7f7af21) * Avoid semantic markup for stable-6. --------- Co-authored-by: snail59 <25689269+snail59@users.noreply.github.com> Co-authored-by: Felix Fontein --- .../fragments/7180-make_params_without_value.yml | 2 ++ plugins/modules/make.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7180-make_params_without_value.yml diff --git a/changelogs/fragments/7180-make_params_without_value.yml b/changelogs/fragments/7180-make_params_without_value.yml new file mode 100644 index 0000000000..114b5b48c8 --- /dev/null +++ b/changelogs/fragments/7180-make_params_without_value.yml @@ -0,0 +1,2 @@ +minor_changes: + - make - allows ``params`` to be used without value (https://github.com/ansible-collections/community.general/pull/7180). diff --git a/plugins/modules/make.py b/plugins/modules/make.py index ebff6cfe11..1964d74eea 100644 --- a/plugins/modules/make.py +++ b/plugins/modules/make.py @@ -49,6 +49,7 @@ options: params: description: - Any extra parameters to pass to make. + - If the value is empty, only the key will be used. For example, C(FOO:) will produce C(FOO), not C(FOO=). type: dict target: description: @@ -81,6 +82,18 @@ EXAMPLES = r''' chdir: /home/ubuntu/cool-project target: all file: /some-project/Makefile + +- name: build arm64 kernel on FreeBSD, with 16 parallel jobs + community.general.make: + chdir: /usr/src + jobs: 16 + target: buildkernel + params: + # This adds -DWITH_FDT to the command line: + -DWITH_FDT: + # The following adds TARGET=arm64 TARGET_ARCH=aarch64 to the command line: + TARGET: arm64 + TARGET_ARCH: aarch64 ''' RETURN = r''' @@ -174,7 +187,7 @@ def main(): make_path = module.get_bin_path('make', required=True) make_target = module.params['target'] if module.params['params'] is not None: - make_parameters = [k + '=' + str(v) for k, v in iteritems(module.params['params'])] + make_parameters = [k + (('=' + str(v)) if v is not None else '') for k, v in iteritems(module.params['params'])] else: make_parameters = []