From 8989212fd2917e043579f14aaf6eb780b99f282b Mon Sep 17 00:00:00 2001 From: Milad Soufastai Date: Tue, 22 Sep 2015 18:53:58 -0400 Subject: [PATCH 1/2] Adding the --sudo flag for CPANM use since the sudo: yes on the task doesn't work --- packaging/language/cpanm.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packaging/language/cpanm.py b/packaging/language/cpanm.py index 0bee74de4cc..af7224ce5ce 100644 --- a/packaging/language/cpanm.py +++ b/packaging/language/cpanm.py @@ -64,6 +64,12 @@ options: required: false default: false version_added: "2.0" + use_sudo: + description: + - Use sudo flag for cpanm + required: false + default: false + version_added: "2.0" 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)" @@ -87,6 +93,9 @@ EXAMPLES = ''' # install Dancer perl package from a specific mirror - cpanm: name=Dancer mirror=http://cpan.cpantesters.org/ + +# install Dancer perl package using --sudo flag +- cpanm: name=Dancer use_sudo=yes ''' def _is_package_installed(module, name, locallib, cpanm): @@ -124,6 +133,9 @@ def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, if installdeps is True: cmd = "{cmd} --installdeps".format(cmd=cmd) + if use_sudo is True: + cmd = "{cmd} --sudo".format(cmd=cmd) + return cmd @@ -136,6 +148,7 @@ def main(): mirror=dict(default=None, required=False), mirror_only=dict(default=False, type='bool'), installdeps=dict(default=False, type='bool'), + use_sudo=dict(default=False, type='bool'), ) module = AnsibleModule( @@ -151,6 +164,7 @@ def main(): mirror = module.params['mirror'] mirror_only = module.params['mirror_only'] installdeps = module.params['installdeps'] + use_sudo = module.params['use_sudo'] changed = False From b5207d0fc65eb985f27820bb29200e956c9a6717 Mon Sep 17 00:00:00 2001 From: Milad Soufastai Date: Wed, 23 Sep 2015 09:40:36 -0400 Subject: [PATCH 2/2] Updating Description to provide better explanation of what the use_sudo flag does --- packaging/language/cpanm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/language/cpanm.py b/packaging/language/cpanm.py index af7224ce5ce..82a6b5d0a0c 100644 --- a/packaging/language/cpanm.py +++ b/packaging/language/cpanm.py @@ -66,7 +66,7 @@ options: version_added: "2.0" use_sudo: description: - - Use sudo flag for cpanm + - Use this if you want to install modules to the system perl include path. required: false default: false version_added: "2.0" @@ -94,7 +94,7 @@ EXAMPLES = ''' # install Dancer perl package from a specific mirror - cpanm: name=Dancer mirror=http://cpan.cpantesters.org/ -# install Dancer perl package using --sudo flag +# install Dancer perl package into the system root path - cpanm: name=Dancer use_sudo=yes '''