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
934f4163
Commit
934f4163
authored
Feb 17, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid the 'state=null' coming back from the service module.
parent
fa21b413
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
library/service
+23
-3
No files found.
library/service
View file @
934f4163
...
...
@@ -237,7 +237,7 @@ class Service(object):
def
check_service_changed
(
self
):
if
self
.
state
and
self
.
running
is
None
:
self
.
module
.
fail_json
(
msg
=
"failed determining
the current service state => state stays unchanged
"
)
self
.
module
.
fail_json
(
msg
=
"failed determining
service state, possible typo of service name?
"
)
# Find out if state has changed
if
not
self
.
running
and
self
.
state
in
[
"started"
,
"running"
]:
self
.
changed
=
True
...
...
@@ -420,6 +420,9 @@ class LinuxService(Service):
# TODO: lookup if we can use a return code for this instead?
self
.
running
=
True
return
self
.
running
def
service_enable
(
self
):
# we change argument depending on real binary used
# update-rc.d wants enable/disable while
...
...
@@ -666,8 +669,25 @@ def main():
result
[
'changed'
]
=
service
.
changed
if
service
.
module
.
params
[
'enabled'
]:
result
[
'enabled'
]
=
service
.
module
.
params
[
'enabled'
]
if
service
.
state
:
result
[
'state'
]
=
service
.
state
#if service.state:
# result['state'] = service.state
print
"getting state!"
if
not
service
.
module
.
params
[
'state'
]:
status
=
service
.
get_service_status
()
if
status
is
None
:
result
[
'state'
]
=
'absent'
elif
status
is
False
:
result
[
'state'
]
=
'started'
else
:
result
[
'state'
]
=
'stopped'
else
:
# as we may have just bounced the service the service command may not
# report accurate state at this moment so just show what we ran
if
service
.
module
.
params
[
'state'
]
in
[
'started'
,
'restarted'
]:
result
[
'state'
]
=
'started'
else
:
result
[
'state'
]
=
'stopped'
module
.
exit_json
(
**
result
)
...
...
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