From 2ca201feaa3b491e53dcc8d420e171eb167a652a Mon Sep 17 00:00:00 2001 From: Andreas Skarmutsos Lindh Date: Thu, 20 Aug 2015 09:57:46 +0200 Subject: [PATCH] cpanm: add installdeps option --- packaging/language/cpanm.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packaging/language/cpanm.py b/packaging/language/cpanm.py index 3749fd29db2..b6bdf0c67a0 100644 --- a/packaging/language/cpanm.py +++ b/packaging/language/cpanm.py @@ -58,6 +58,11 @@ options: - Use the mirror's index file instead of the CPAN Meta DB required: false default: false + installdeps: + description: + - Only install dependencies + required: false + default: false notes: - Please note that U(http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm) must be installed on the remote host. author: "Franck Cuny (@franckcuny)" @@ -91,10 +96,11 @@ def _is_package_installed(module, name, locallib, cpanm): res, stdout, stderr = module.run_command(cmd, check_rc=False) if res == 0: return True - else: + else: return False -def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm): +def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, + installdeps, cpanm): # this code should use "%s" like everything else and just return early but not fixing all of it now. # don't copy stuff like this if from_path: @@ -114,6 +120,9 @@ def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpan if mirror_only is True: cmd = "{cmd} --mirror-only".format(cmd=cmd) + if installdeps is True: + cmd = "{cmd} --installdeps".format(cmd=cmd) + return cmd @@ -125,6 +134,7 @@ def main(): locallib=dict(default=None, required=False), mirror=dict(default=None, required=False), mirror_only=dict(default=False, type='bool'), + installdeps=dict(default=False, type='bool'), ) module = AnsibleModule( @@ -139,6 +149,7 @@ def main(): locallib = module.params['locallib'] mirror = module.params['mirror'] mirror_only = module.params['mirror_only'] + installdeps = module.params['installdeps'] changed = False @@ -146,7 +157,8 @@ def main(): if not installed: out_cpanm = err_cpanm = '' - cmd = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm) + cmd = _build_cmd_line(name, from_path, notest, locallib, mirror, + mirror_only, installdeps, cpanm) rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)