Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
abd7c0b5
Commit
abd7c0b5
authored
Mar 03, 2014
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cpanm module to newer module patterns
parent
4da0428d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
library/packaging/cpanm
+9
-14
No files found.
library/cpanm
→
library/
packaging/
cpanm
View file @
abd7c0b5
...
...
@@ -69,12 +69,12 @@ notes:
author: Franck Cuny
'''
def
_is_package_installed
(
name
,
locallib
,
cpanm
):
def
_is_package_installed
(
module
,
name
,
locallib
,
cpanm
):
cmd
=
""
if
locallib
:
cmd
=
"PERL5LIB={locallib}/lib/perl5"
.
format
(
locallib
=
locallib
)
cmd
=
"{cmd} perl -M{name} -e '1'"
.
format
(
cmd
=
cmd
,
name
=
name
)
res
,
stdout
,
stderr
=
_run
(
cmd
)
res
,
stdout
,
stderr
=
module
.
run_command
(
cmd
,
check_rc
=
False
)
installed
=
True
if
res
==
0
else
False
return
installed
...
...
@@ -97,18 +97,11 @@ def _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm):
return
cmd
def
_run
(
cmd
):
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
stdout
,
stderr
=
process
.
communicate
()
return
(
process
.
returncode
,
stdout
,
stderr
)
def
main
():
arg_spec
=
dict
(
name
=
dict
(
default
=
None
,
required
=
False
,
aliases
=
[
'pkg'
]),
from_path
=
dict
(
default
=
None
,
required
=
False
),
notest
=
dict
(
default
=
False
,
choices
=
BOOLEANS
),
notest
=
dict
(
default
=
False
,
type
=
'bool'
),
locallib
=
dict
(
default
=
None
,
required
=
False
),
mirror
=
dict
(
default
=
None
,
required
=
False
)
)
...
...
@@ -124,16 +117,17 @@ def main():
from_path
=
module
.
params
[
'from_path'
]
notest
=
module
.
boolean
(
module
.
params
.
get
(
'notest'
,
False
))
locallib
=
module
.
params
[
'locallib'
]
mirror
=
module
.
params
[
'mirror'
]
changed
=
False
installed
=
_is_package_installed
(
name
,
locallib
,
cpanm
)
installed
=
_is_package_installed
(
module
,
name
,
locallib
,
cpanm
)
if
not
installed
:
out_cpanm
=
err_cpanm
=
''
cmd
=
_build_cmd_line
(
name
,
from_path
,
notest
,
locallib
,
mirror
,
cpanm
)
rc_cpanm
,
out_cpanm
,
err_cpanm
=
_run
(
cmd
)
rc_cpanm
,
out_cpanm
,
err_cpanm
=
module
.
run_command
(
cmd
,
check_rc
=
False
)
if
rc_cpanm
!=
0
:
module
.
fail_json
(
msg
=
err_cpanm
,
cmd
=
cmd
)
...
...
@@ -144,6 +138,7 @@ def main():
module
.
exit_json
(
changed
=
changed
,
binary
=
cpanm
,
name
=
name
)
# include magic from lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
# import module snippets
from
ansible.module_utils.basic
import
*
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment