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
72eaa057
Commit
72eaa057
authored
Sep 11, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow service module to manage services not ending in .service
Fixes #3417
parent
5110b2d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
library/system/service
+16
-6
No files found.
library/system/service
View file @
72eaa057
...
@@ -392,16 +392,26 @@ class LinuxService(Service):
...
@@ -392,16 +392,26 @@ class LinuxService(Service):
if
not
location
.
get
(
'systemctl'
,
None
):
if
not
location
.
get
(
'systemctl'
,
None
):
return
False
return
False
# default to .service if the unit type is not specified
if
name
.
find
(
'.'
)
>
0
:
unit_name
,
unit_type
=
name
.
rsplit
(
'.'
,
1
)
if
unit_type
not
in
(
"service"
,
"socket"
,
"device"
,
"mount"
,
"automount"
,
"swap"
,
"target"
,
"path"
,
"timer"
,
"snapshot"
):
name
=
"
%
s.service"
%
name
else
:
name
=
"
%
s.service"
%
name
rc
,
out
,
err
=
self
.
execute_command
(
"
%
s list-unit-files"
%
(
location
[
'systemctl'
]))
rc
,
out
,
err
=
self
.
execute_command
(
"
%
s list-unit-files"
%
(
location
[
'systemctl'
]))
# adjust the service name to account for template service unit files
# adjust the service name to account for template service unit files
index
=
name
.
find
(
'@'
)
index
=
name
.
find
(
'@'
)
if
index
!=
-
1
:
if
index
!=
-
1
:
self
.
name
=
name
=
name
[:
index
+
1
]
name
=
name
[:
index
+
1
]
look_for
=
"
%
s.service"
%
nam
e
self
.
__systemd_unit
=
Non
e
for
line
in
out
.
splitlines
():
for
line
in
out
.
splitlines
():
if
line
.
startswith
(
look_for
):
if
line
.
startswith
(
name
):
self
.
__systemd_unit
=
name
return
True
return
True
return
False
return
False
...
@@ -540,7 +550,7 @@ class LinuxService(Service):
...
@@ -540,7 +550,7 @@ class LinuxService(Service):
return
return
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s
.service"
%
(
self
.
enable_cmd
,
self
.
name
))
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s
"
%
(
self
.
enable_cmd
,
self
.
__systemd_unit
))
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
if
"UnitFileState"
in
d
:
if
"UnitFileState"
in
d
:
...
@@ -626,7 +636,7 @@ class LinuxService(Service):
...
@@ -626,7 +636,7 @@ class LinuxService(Service):
if
self
.
enable_cmd
.
endswith
(
"rc-update"
):
if
self
.
enable_cmd
.
endswith
(
"rc-update"
):
args
=
(
self
.
enable_cmd
,
add_delete
,
self
.
name
+
" "
+
self
.
runlevel
)
args
=
(
self
.
enable_cmd
,
add_delete
,
self
.
name
+
" "
+
self
.
runlevel
)
elif
self
.
enable_cmd
.
endswith
(
"systemctl"
):
elif
self
.
enable_cmd
.
endswith
(
"systemctl"
):
args
=
(
self
.
enable_cmd
,
enable_disable
,
self
.
name
+
".service"
)
args
=
(
self
.
enable_cmd
,
enable_disable
,
self
.
__systemd_unit
)
else
:
else
:
args
=
(
self
.
enable_cmd
,
self
.
name
,
on_off
)
args
=
(
self
.
enable_cmd
,
self
.
name
,
on_off
)
...
@@ -650,7 +660,7 @@ class LinuxService(Service):
...
@@ -650,7 +660,7 @@ class LinuxService(Service):
else
:
else
:
# 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
arguments
=
"
%
s
%
s"
%
(
self
.
name
,
arguments
)
arguments
=
"
%
s
%
s"
%
(
self
.
__systemd_unit
,
arguments
)
elif
self
.
svc_initscript
:
elif
self
.
svc_initscript
:
# upstart
# upstart
svc_cmd
=
"
%
s"
%
self
.
svc_initscript
svc_cmd
=
"
%
s"
%
self
.
svc_initscript
...
...
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