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
b5f3881e
Commit
b5f3881e
authored
Mar 24, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2491 from tones111/to-upstream
Support systemd template service unit files
parents
93402984
b545b4c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
library/service
+24
-9
No files found.
library/service
View file @
b5f3881e
...
@@ -369,10 +369,20 @@ class LinuxService(Service):
...
@@ -369,10 +369,20 @@ class LinuxService(Service):
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 list-unit-files"
%
(
location
[
'systemctl'
]))
look_for
=
"
%
s.service"
%
self
.
name
if
look_for
in
out
:
# adjust the service name to account for template service unit files
self
.
enable_cmd
=
location
[
'systemctl'
]
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.)
# Locate a tool for runtime service management (start, stop etc.)
self
.
svc_cmd
=
''
self
.
svc_cmd
=
''
...
@@ -473,10 +483,15 @@ class LinuxService(Service):
...
@@ -473,10 +483,15 @@ class LinuxService(Service):
return
return
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
if
self
.
enable_cmd
.
endswith
(
"systemctl"
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s is-enabled
%
s.service"
%
(
self
.
enable_cmd
,
self
.
name
))
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s show
%
s.service"
%
(
self
.
enable_cmd
,
self
.
name
))
if
self
.
enable
and
rc
==
0
:
return
d
=
dict
(
line
.
split
(
'='
,
1
)
for
line
in
out
.
splitlines
())
elif
not
self
.
enable
and
rc
==
1
:
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
return
# we change argument depending on real binary used
# we change argument depending on real binary used
...
@@ -499,7 +514,7 @@ class LinuxService(Service):
...
@@ -499,7 +514,7 @@ class LinuxService(Service):
self
.
changed
=
True
self
.
changed
=
True
if
self
.
module
.
check_mode
and
changed
:
if
self
.
module
.
check_mode
and
self
.
changed
:
self
.
module
.
exit_json
(
changed
=
True
)
self
.
module
.
exit_json
(
changed
=
True
)
return
self
.
execute_command
(
"
%
s
%
s
%
s"
%
args
)
return
self
.
execute_command
(
"
%
s
%
s
%
s"
%
args
)
...
...
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