|
|
|
|
@ -97,16 +97,17 @@ def parse_out(string):
|
|
|
|
|
def has_changed(string):
|
|
|
|
|
return (re.match("Nothing to install or update", string) != None)
|
|
|
|
|
|
|
|
|
|
def composer_install(module, options):
|
|
|
|
|
def composer_install(module, command, options):
|
|
|
|
|
php_path = module.get_bin_path("php", True, ["/usr/local/bin"])
|
|
|
|
|
composer_path = module.get_bin_path("composer", True, ["/usr/local/bin"])
|
|
|
|
|
cmd = "%s %s install %s" % (php_path, composer_path, " ".join(options))
|
|
|
|
|
cmd = "%s %s %s %s" % (php_path, composer_path, command, " ".join(options))
|
|
|
|
|
|
|
|
|
|
return module.run_command(cmd)
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
|
argument_spec = dict(
|
|
|
|
|
command = dict(default="install", type="str", required=False),
|
|
|
|
|
working_dir = dict(aliases=["working-dir"], required=True),
|
|
|
|
|
prefer_source = dict(default="no", type="bool", aliases=["prefer-source"]),
|
|
|
|
|
prefer_dist = dict(default="no", type="bool", aliases=["prefer-dist"]),
|
|
|
|
|
@ -129,6 +130,10 @@ def main():
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
options.add("--dry-run")
|
|
|
|
|
|
|
|
|
|
# Get composer command with fallback to default
|
|
|
|
|
command = module.params['command']
|
|
|
|
|
del module.params['command'];
|
|
|
|
|
|
|
|
|
|
# Prepare options
|
|
|
|
|
for i in module.params:
|
|
|
|
|
opt = "--%s" % i.replace("_","-")
|
|
|
|
|
@ -138,7 +143,7 @@ def main():
|
|
|
|
|
elif isinstance(p, (str)):
|
|
|
|
|
options.add("%s=%s" % (opt, p))
|
|
|
|
|
|
|
|
|
|
rc, out, err = composer_install(module, options)
|
|
|
|
|
rc, out, err = composer_install(module, command, options)
|
|
|
|
|
|
|
|
|
|
if rc != 0:
|
|
|
|
|
output = parse_out(err)
|
|
|
|
|
|