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
6c9bb35f
Commit
6c9bb35f
authored
Feb 28, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2231 from tonk/devel
Service command handling fix when no upstart config file
parents
23bcb647
05c70ca7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
library/service
+13
-10
No files found.
library/service
View file @
6c9bb35f
...
@@ -283,7 +283,7 @@ class Service(object):
...
@@ -283,7 +283,7 @@ class Service(object):
RCFILE
=
open
(
self
.
rcconf_file
,
"r"
)
RCFILE
=
open
(
self
.
rcconf_file
,
"r"
)
new_rc_conf
=
[]
new_rc_conf
=
[]
# Build a list containing the possibly modified file.
# Build a list containing the possibly modified file.
for
rcline
in
RCFILE
:
for
rcline
in
RCFILE
:
# Parse line removing whitespaces, quotes, etc.
# Parse line removing whitespaces, quotes, etc.
rcarray
=
shlex
.
split
(
rcline
,
comments
=
True
)
rcarray
=
shlex
.
split
(
rcline
,
comments
=
True
)
...
@@ -294,7 +294,7 @@ class Service(object):
...
@@ -294,7 +294,7 @@ class Service(object):
# Since the proper entry already exists we can stop iterating.
# Since the proper entry already exists we can stop iterating.
changed
=
False
changed
=
False
break
break
else
:
else
:
# We found the key but the value is wrong, replace with new entry.
# We found the key but the value is wrong, replace with new entry.
rcline
=
entry
rcline
=
entry
changed
=
True
changed
=
True
...
@@ -363,14 +363,17 @@ class LinuxService(Service):
...
@@ -363,14 +363,17 @@ class LinuxService(Service):
elif
location
.
get
(
'update-rc.d'
,
None
)
and
os
.
path
.
exists
(
"/etc/init/
%
s.conf"
%
self
.
name
):
elif
location
.
get
(
'update-rc.d'
,
None
)
and
os
.
path
.
exists
(
"/etc/init/
%
s.conf"
%
self
.
name
):
# service is managed by upstart
# service is managed by upstart
self
.
enable_cmd
=
location
[
'update-rc.d'
]
self
.
enable_cmd
=
location
[
'update-rc.d'
]
elif
location
.
get
(
'update-rc.d'
,
None
)
and
os
.
path
.
exists
(
"/etc/init.d/
%
s"
%
self
.
name
):
# service is managed by with SysV init scripts, but with update-rc.d
self
.
enable_cmd
=
location
[
'update-rc.d'
]
elif
location
.
get
(
'systemctl'
,
None
):
elif
location
.
get
(
'systemctl'
,
None
):
# verify service is managed by systemd
# verify service is managed by systemd
rc
,
out
,
err
=
self
.
execute_command
(
"
%
s --all"
%
(
location
[
'systemctl'
]))
rc
,
out
,
err
=
self
.
execute_command
(
"
%
s --all"
%
(
location
[
'systemctl'
]))
look_for
=
"
%
s.service"
%
self
.
name
look_for
=
"
%
s.service"
%
self
.
name
if
look_for
in
out
:
if
look_for
in
out
:
self
.
enable_cmd
=
location
[
'systemctl'
]
self
.
enable_cmd
=
location
[
'systemctl'
]
# Locate a tool for runtime service management (start, stop etc.)
# Locate a tool for runtime service management (start, stop etc.)
self
.
svc_cmd
=
''
self
.
svc_cmd
=
''
if
location
.
get
(
'service'
,
None
)
and
os
.
path
.
exists
(
"/etc/init.d/
%
s"
%
self
.
name
):
if
location
.
get
(
'service'
,
None
)
and
os
.
path
.
exists
(
"/etc/init.d/
%
s"
%
self
.
name
):
...
@@ -512,7 +515,7 @@ class LinuxService(Service):
...
@@ -512,7 +515,7 @@ class LinuxService(Service):
# systemd commands take the form <cmd> <action> <name>
# systemd commands take the form <cmd> <action> <name>
svc_cmd
=
self
.
svc_cmd
svc_cmd
=
self
.
svc_cmd
self
.
arguments
=
"
%
s
%
s"
%
(
self
.
name
,
self
.
arguments
)
self
.
arguments
=
"
%
s
%
s"
%
(
self
.
name
,
self
.
arguments
)
elif
self
.
svc_initscript
:
elif
self
.
svc_initscript
:
# upstart
# upstart
svc_cmd
=
"
%
s"
%
self
.
svc_initscript
svc_cmd
=
"
%
s"
%
self
.
svc_initscript
...
@@ -531,7 +534,7 @@ class LinuxService(Service):
...
@@ -531,7 +534,7 @@ class LinuxService(Service):
else
:
else
:
# SysV or systemd
# SysV or systemd
rc1
,
stdout1
,
stderr1
=
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
'stop'
,
self
.
name
,
self
.
arguments
),
daemonize
=
True
)
rc1
,
stdout1
,
stderr1
=
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
'stop'
,
self
.
name
,
self
.
arguments
),
daemonize
=
True
)
if
svc_cmd
!=
''
:
if
svc_cmd
!=
''
:
# upstart
# upstart
rc2
,
stdout2
,
stderr2
=
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
svc_cmd
,
'start'
,
self
.
arguments
),
daemonize
=
True
)
rc2
,
stdout2
,
stderr2
=
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
svc_cmd
,
'start'
,
self
.
arguments
),
daemonize
=
True
)
...
@@ -587,7 +590,7 @@ class FreeBsdService(Service):
...
@@ -587,7 +590,7 @@ class FreeBsdService(Service):
for
rcfile
in
rcfiles
:
for
rcfile
in
rcfiles
:
if
os
.
path
.
isfile
(
rcfile
):
if
os
.
path
.
isfile
(
rcfile
):
self
.
rcconf_file
=
rcfile
self
.
rcconf_file
=
rcfile
self
.
rcconf_key
=
"
%
s_enable"
%
self
.
name
self
.
rcconf_key
=
"
%
s_enable"
%
self
.
name
# FIXME: detect the enablement state rather than just running the command
# FIXME: detect the enablement state rather than just running the command
...
@@ -681,7 +684,7 @@ class NetBsdService(Service):
...
@@ -681,7 +684,7 @@ class NetBsdService(Service):
for
rcfile
in
rcfiles
:
for
rcfile
in
rcfiles
:
if
os
.
path
.
isfile
(
rcfile
):
if
os
.
path
.
isfile
(
rcfile
):
self
.
rcconf_file
=
rcfile
self
.
rcconf_file
=
rcfile
self
.
rcconf_key
=
"
%
s"
%
self
.
name
self
.
rcconf_key
=
"
%
s"
%
self
.
name
return
self
.
service_enable_rcconf
()
return
self
.
service_enable_rcconf
()
...
@@ -764,10 +767,10 @@ def main():
...
@@ -764,10 +767,10 @@ def main():
if
service
.
module
.
params
[
'enabled'
]:
if
service
.
module
.
params
[
'enabled'
]:
result
[
'enabled'
]
=
service
.
module
.
params
[
'enabled'
]
result
[
'enabled'
]
=
service
.
module
.
params
[
'enabled'
]
if
not
service
.
module
.
params
[
'state'
]:
if
not
service
.
module
.
params
[
'state'
]:
status
=
service
.
get_service_status
()
status
=
service
.
get_service_status
()
if
status
is
None
:
if
status
is
None
:
result
[
'state'
]
=
'absent'
result
[
'state'
]
=
'absent'
elif
status
is
False
:
elif
status
is
False
:
result
[
'state'
]
=
'started'
result
[
'state'
]
=
'started'
else
:
else
:
...
...
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