From a396c18a61677257ef305fcdc10b2ca3cdeab9ce Mon Sep 17 00:00:00 2001 From: Deepakkothandan Date: Thu, 29 Jun 2017 23:08:30 +0200 Subject: [PATCH] composer: add param for custom PHP Executable path (#26107) --- .../modules/packaging/language/composer.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/language/composer.py b/lib/ansible/modules/packaging/language/composer.py index 73183f1e119..b3735facb48 100644 --- a/lib/ansible/modules/packaging/language/composer.py +++ b/lib/ansible/modules/packaging/language/composer.py @@ -50,6 +50,13 @@ options: - Composer arguments like required package, version and so on. required: false default: null + executable: + version_added: "2.4" + description: + - Path to PHP Executable on the remote host, if PHP is not in PATH + required: false + default: null + aliases: [ "php_path" ] working_dir: description: - Directory of your project (see --working-dir). This is required when @@ -177,7 +184,12 @@ def get_available_options(module, command='install'): def composer_command(module, command, arguments="", options=None, global_command=False): if options is None: options = [] - php_path = module.get_bin_path("php", True, ["/usr/local/bin"]) + + if module.params['executable'] is None: + php_path = module.get_bin_path("php", True, ["/usr/local/bin"]) + else: + php_path = module.params['executable'] + composer_path = module.get_bin_path("composer", True, ["/usr/local/bin"]) 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) @@ -188,6 +200,7 @@ def main(): argument_spec=dict( command=dict(default="install", type="str", required=False), arguments=dict(default="", type="str", required=False), + executable=dict(type="path", required=False, aliases=["php_path"]), working_dir=dict(type="path", aliases=["working-dir"]), global_command=dict(default=False, type="bool", aliases=["global-command"]), prefer_source=dict(default=False, type="bool", aliases=["prefer-source"]),