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
bdb39058
Commit
bdb39058
authored
Aug 21, 2012
by
Stephen Fromm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate apt_repository, group, and supervisorctl to use module.get_bin_path
parent
4c62e495
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
18 deletions
+12
-18
library/apt_repository
+5
-12
library/group
+4
-5
library/supervisorctl
+3
-1
No files found.
library/apt_repository
View file @
bdb39058
...
...
@@ -26,17 +26,7 @@
import
platform
APT
=
"/usr/bin/apt-get"
def
_find_binary
(
module
):
binaries
=
[
'/usr/bin/add-apt-repository'
]
for
e
in
binaries
:
if
os
.
path
.
exists
(
e
):
return
e
module
.
fail_json
(
msg
=
'Unabled to find any of the following executables '
'
%
s'
%
binaries
)
ADD_APT_REPO
=
'add-apt-repository'
def
_run
(
cmd
):
# returns (rc, stdout, stderr) from shell command
...
...
@@ -56,7 +46,10 @@ def main():
module
=
AnsibleModule
(
argument_spec
=
arg_spec
)
add_apt_repository
=
_find_binary
(
module
)
add_apt_repository
=
module
.
get_bin_path
(
ADD_APT_REPO
)
if
add_apt_repository
is
None
:
module
.
fail_json
(
msg
=
'Unabled to find any of the following executables '
'
%
s'
%
binaries
)
repo
=
module
.
params
[
'repo'
]
state
=
module
.
params
[
'state'
]
...
...
library/group
View file @
bdb39058
...
...
@@ -21,12 +21,11 @@
import
grp
def
get_bin_path
(
module
,
arg
):
if
os
.
path
.
exists
(
'/usr/sbin/
%
s'
%
arg
):
return
'/usr/sbin/
%
s'
%
arg
elif
os
.
path
.
exists
(
'/sbin/
%
s'
%
arg
):
return
'/sbin/
%
s'
%
arg
else
:
bin
=
module
.
get_bin_path
(
arg
)
if
bin
is
None
:
module
.
fail_json
(
msg
=
"Cannot find
%
s"
%
arg
)
else
:
return
bin
def
group_del
(
module
,
group
):
cmd
=
[
get_bin_path
(
module
,
'groupdel'
),
group
]
...
...
library/supervisorctl
View file @
bdb39058
...
...
@@ -52,7 +52,9 @@ def main():
name
=
module
.
params
[
'name'
]
state
=
module
.
params
[
'state'
]
SUPERVISORCTL
=
_find_supervisorctl
()
SUPERVISORCTL
=
module
.
get_bin_path
(
'supervisorctl'
)
if
SUPERVISORCTL
is
None
:
module
.
fail_json
(
msg
=
'supervisorctl is not installed'
)
if
SUPERVISORCTL
is
None
:
module
.
fail_json
(
msg
=
'supervisorctl is not installed'
)
...
...
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