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
b545b4c5
Commit
b545b4c5
authored
Mar 23, 2013
by
Paul Sbarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service: add systemd template support
parent
4cfda2a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
8 deletions
+23
-8
library/service
+23
-8
No files found.
library/service
View file @
b545b4c5
...
...
@@ -369,10 +369,20 @@ class LinuxService(Service):
elif
location
.
get
(
'systemctl'
,
None
):
# verify service is managed by systemd
rc
,
out
,
err
=
self
.
execute_command
(
"
%
s --all"
%
(
location
[
'systemctl'
]))
look_for
=
"
%
s.service"
%
self
.
name
if
look_for
in
out
:
self
.
enable_cmd
=
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
index
=
self
.
name
.
find
(
'@'
)
if
index
==
-
1
:
name
=
self
.
name
else
:
name
=
self
.
name
[:
index
+
1
]
look_for
=
"
%
s.service"
%
name
for
line
in
out
.
splitlines
():
if
line
.
startswith
(
look_for
):
self
.
enable_cmd
=
location
[
'systemctl'
]
break
# Locate a tool for runtime service management (start, stop etc.)
self
.
svc_cmd
=
''
...
...
@@ -473,10 +483,15 @@ class LinuxService(Service):
return
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s is-enabled
%
s.service"
%
(
self
.
enable_cmd
,
self
.
name
))
if
self
.
enable
and
rc
==
0
:
return
elif
not
self
.
enable
and
rc
==
1
:
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s.service"
%
(
self
.
enable_cmd
,
self
.
name
))
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
if
"UnitFileState"
in
d
:
if
self
.
enable
and
d
[
"UnitFileState"
]
==
"enabled"
:
return
elif
not
self
.
enable
and
d
[
"UnitFileState"
]
==
"disabled"
:
return
elif
not
self
.
enable
:
return
# we change argument depending on real binary used
...
...
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