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
ff82f0a1
Commit
ff82f0a1
authored
Jul 28, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further service module tweaks
parent
e9c4eb36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
lib/ansible/module_common.py
+2
-1
library/service
+11
-10
No files found.
lib/ansible/module_common.py
View file @
ff82f0a1
...
...
@@ -134,9 +134,10 @@ class AnsibleModule(object):
def boolean(self, arg):
''' return a bool for the arg '''
if arg is None or type(arg) == bool:
return arg
if type(arg) in types.StringTypes:
arg = arg.lower()
if arg in BOOLEANS_TRUE:
return True
elif arg in BOOLEANS_FALSE:
...
...
library/service
View file @
ff82f0a1
...
...
@@ -19,12 +19,13 @@
SERVICE
=
None
CHKCONFIG
=
None
INITCTL
=
None
def
_find_binaries
(
m
):
# list of possible paths for service/chkconfig binaries
# with the most probable first
global
CHKCONFIG
global
SERVICE
global
CHKCONFIG
global
INITCTL
paths
=
[
'/sbin'
,
'/usr/sbin'
,
'/bin'
,
'/usr/bin'
]
binaries
=
[
'service'
,
'chkconfig'
,
'update-rc.d'
,
'initctl'
]
...
...
@@ -119,10 +120,11 @@ def _do_enable(name, enable):
valid_argument
[
'on'
]
=
"enable"
valid_argument
[
'off'
]
=
"disable"
if
enable
.
lower
()
in
[
'on'
,
'true'
,
'yes'
,
'enable'
]:
rc
,
stdout
,
stderr
=
_run
(
"
%
s
%
s
%
s"
%
(
CHKCONFIG
,
name
,
valid_argument
[
'on'
]))
elif
enable
.
lower
()
in
[
'off'
,
'false'
,
'no'
,
'disable'
]:
rc
,
stdout
,
stderr
=
_run
(
"
%
s
%
s
%
s"
%
(
CHKCONFIG
,
name
,
valid_argument
[
'off'
]))
if
enable
is
not
None
:
if
enable
:
rc
,
stdout
,
stderr
=
_run
(
"
%
s
%
s
%
s"
%
(
CHKCONFIG
,
name
,
valid_argument
[
'on'
]))
else
:
rc
,
stdout
,
stderr
=
_run
(
"
%
s
%
s
%
s"
%
(
CHKCONFIG
,
name
,
valid_argument
[
'off'
]))
return
rc
,
stdout
,
stderr
...
...
@@ -130,15 +132,14 @@ def main():
module
=
AnsibleModule
(
argument_spec
=
dict
(
name
=
dict
(
required
=
True
),
state
=
dict
(
choices
=
[
'running'
,
'started'
,
'stopped'
,
'restarted'
,
'reloaded'
]),
state
=
dict
(
required
=
True
,
choices
=
[
'running'
,
'started'
,
'stopped'
,
'restarted'
,
'reloaded'
]),
enable
=
dict
(
choices
=
BOOLEANS
)
)
)
p
=
module
.
params
name
=
p
[
'name'
]
state
=
p
.
get
(
'state'
,
None
)
enable
=
module
.
bool
(
p
.
get
(
'enable'
,
None
))
name
=
module
.
params
[
'name'
]
state
=
module
.
params
[
'state'
]
enable
=
module
.
boolean
(
module
.
params
.
get
(
'enable'
,
None
))
# ===========================================
# find binaries locations on minion
...
...
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