From 3723e458d32b99b68e0d39ab26d9ee263c18ed8c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 28 May 2021 13:24:44 +0200 Subject: [PATCH] composer: add composer_executable (#2650) (#2670) * composer: add composer_executable * Add changelog * Improve documentation thanks to felixfontein Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit c3cab7c68c4eb0d0f80d49356c8be52d0bb849ef) Co-authored-by: Amin Vakil --- .../2650-composer-add_composer_executable.yml | 3 +++ plugins/modules/packaging/language/composer.py | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/2650-composer-add_composer_executable.yml diff --git a/changelogs/fragments/2650-composer-add_composer_executable.yml b/changelogs/fragments/2650-composer-add_composer_executable.yml new file mode 100644 index 0000000000..b1cccc689c --- /dev/null +++ b/changelogs/fragments/2650-composer-add_composer_executable.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - composer - add ``composer_executable`` option (https://github.com/ansible-collections/community.general/issues/2649). diff --git a/plugins/modules/packaging/language/composer.py b/plugins/modules/packaging/language/composer.py index 64157cb685..86fe7bdea3 100644 --- a/plugins/modules/packaging/language/composer.py +++ b/plugins/modules/packaging/language/composer.py @@ -117,9 +117,14 @@ options: default: false type: bool aliases: [ ignore-platform-reqs ] + composer_executable: + type: path + description: + - Path to composer executable on the remote host, if composer is not in C(PATH) or a custom composer is needed. + version_added: 3.2.0 requirements: - php - - composer installed in bin path (recommended /usr/local/bin) + - composer installed in bin path (recommended /usr/local/bin) or specified in I(composer_executable) notes: - Default options that are always appended in each execution are --no-ansi, --no-interaction and --no-progress if available. - We received reports about issues on macOS if composer was installed by Homebrew. Please use the official install method to avoid issues. @@ -187,7 +192,11 @@ def composer_command(module, command, arguments="", options=None, global_command else: php_path = module.params['executable'] - composer_path = module.get_bin_path("composer", True, ["/usr/local/bin"]) + if module.params['composer_executable'] is None: + composer_path = module.get_bin_path("composer", True, ["/usr/local/bin"]) + else: + composer_path = module.params['composer_executable'] + cmd = "%s %s %s %s %s %s" % (php_path, composer_path, "global" if global_command else "", command, " ".join(options), arguments) return module.run_command(cmd) @@ -231,6 +240,7 @@ def main(): ignore_platform_reqs=dict( default=False, type="bool", aliases=["ignore-platform-reqs"], deprecated_aliases=[dict(name='ignore-platform-reqs', version='5.0.0', collection_name='community.general')]), + composer_executable=dict(type="path"), ), required_if=[('global_command', False, ['working_dir'])], supports_check_mode=True