From beceac1b35559a5185172349dbc6eb32f8de96b7 Mon Sep 17 00:00:00 2001 From: Ralf Geschke Date: Wed, 21 May 2014 18:01:33 +0200 Subject: [PATCH 1/3] implemented the missing "command" option, defaults to "install"... --- library/packaging/composer | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/packaging/composer b/library/packaging/composer index 16dc420d20..4a609e3c4f 100644 --- a/library/packaging/composer +++ b/library/packaging/composer @@ -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) From b04d42ecd90d1408d9f898288005d3962076740a Mon Sep 17 00:00:00 2001 From: Ralf Geschke Date: Wed, 21 May 2014 18:12:53 +0200 Subject: [PATCH 2/3] added missing description... --- library/packaging/composer | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/packaging/composer b/library/packaging/composer index 4a609e3c4f..d9f43d061a 100644 --- a/library/packaging/composer +++ b/library/packaging/composer @@ -28,6 +28,11 @@ version_added: "1.6" description: - Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you options: + command: + description: + - Composer command like "install", "update" and so option + required: false + default: install working_dir: description: - Directory of your project ( see --working-dir ) @@ -85,7 +90,7 @@ notes: EXAMPLES = ''' # Downloads and installs all the libs and dependencies outlined in the /path/to/project/composer.lock -- composer: working_dir=/path/to/project +- composer: command=install working_dir=/path/to/project ''' import os From c6f3f5b4d7ce610c67f4c8010fdbfc25fa28dbdf Mon Sep 17 00:00:00 2001 From: Ralf Geschke Date: Wed, 21 May 2014 18:14:21 +0200 Subject: [PATCH 3/3] added missing description of composer command --- library/packaging/composer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/packaging/composer b/library/packaging/composer index d9f43d061a..f6d84bbfef 100644 --- a/library/packaging/composer +++ b/library/packaging/composer @@ -30,7 +30,7 @@ description: options: command: description: - - Composer command like "install", "update" and so option + - Composer command like "install", "update" and so on required: false default: install working_dir: