composer: add param for custom PHP Executable path (#26107)

pull/26268/head
Deepakkothandan 8 years ago committed by René Moser
parent 6b49fca7e5
commit a396c18a61

@ -50,6 +50,13 @@ options:
- Composer arguments like required package, version and so on. - Composer arguments like required package, version and so on.
required: false required: false
default: null 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: working_dir:
description: description:
- Directory of your project (see --working-dir). This is required when - 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): def composer_command(module, command, arguments="", options=None, global_command=False):
if options is None: if options is None:
options = [] options = []
if module.params['executable'] is None:
php_path = module.get_bin_path("php", True, ["/usr/local/bin"]) 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"]) 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) 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) return module.run_command(cmd)
@ -188,6 +200,7 @@ def main():
argument_spec=dict( argument_spec=dict(
command=dict(default="install", type="str", required=False), command=dict(default="install", type="str", required=False),
arguments=dict(default="", 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"]), working_dir=dict(type="path", aliases=["working-dir"]),
global_command=dict(default=False, type="bool", aliases=["global-command"]), global_command=dict(default=False, type="bool", aliases=["global-command"]),
prefer_source=dict(default=False, type="bool", aliases=["prefer-source"]), prefer_source=dict(default=False, type="bool", aliases=["prefer-source"]),

Loading…
Cancel
Save