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
7ff2b3be
Commit
7ff2b3be
authored
Sep 30, 2013
by
cdigiovanni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support to disable and enable upstart jobs
parent
ac0a7d96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletions
+32
-1
library/system/service
+32
-1
No files found.
library/system/service
View file @
7ff2b3be
...
...
@@ -430,7 +430,7 @@ class LinuxService(Service):
self
.
enable_cmd
=
location
[
'systemctl'
]
elif
os
.
path
.
exists
(
"/etc/init/
%
s.conf"
%
self
.
name
):
# service is managed by upstart
self
.
enable_cmd
=
location
[
'
update-rc.d
'
]
self
.
enable_cmd
=
location
[
'
initctl
'
]
elif
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'
]
...
...
@@ -537,6 +537,37 @@ class LinuxService(Service):
# to decide whether to run the command here but need something
# similar for upstart
if
self
.
enable_cmd
.
endswith
(
"initctl"
):
def
write_to_override_file
(
file_name
,
file_contents
,
):
override_file
=
open
(
file_name
,
'w'
)
override_file
.
write
(
file_contents
)
override_file
.
close
()
initpath
=
'/etc/init'
manreg
=
re
.
compile
(
'^manual
\
s*$'
,
re
.
M
|
re
.
I
)
conf_file_name
=
"
%
s/
%
s.conf"
%
(
initpath
,
self
.
name
)
override_file_name
=
"
%
s/
%
s.override"
%
(
initpath
,
self
.
name
)
# Check to see if files contain the manual line in .conf and fail if True
if
manreg
.
search
(
open
(
conf_file_name
)
.
read
()):
self
.
module
.
fail_json
(
msg
=
"manual stanza not supported in a .conf file"
)
if
os
.
path
.
exists
(
override_file_name
):
override_file_contents
=
open
(
override_file_name
)
.
read
()
# Remove manual stanza if present and service enabled
if
self
.
enable
and
manreg
.
search
(
override_file_contents
):
write_to_override_file
(
override_file_name
,
manreg
.
sub
(
''
,
override_file_contents
))
# Add manual stanza if not present and service disabled
elif
not
(
self
.
enable
)
and
not
(
manreg
.
search
(
override_file_contents
)):
write_to_override_file
(
override_file_name
,
override_file_contents
+
'
\n
manual
\n
'
)
else
:
return
# Add file with manual stanza if service disabled
elif
not
(
self
.
enable
):
write_to_override_file
(
override_file_name
,
'manual
\n
'
)
else
:
return
if
self
.
enable_cmd
.
endswith
(
"chkconfig"
):
(
rc
,
out
,
err
)
=
self
.
execute_command
(
"
%
s --list
%
s"
%
(
self
.
enable_cmd
,
self
.
name
))
if
'chkconfig --add
%
s'
%
self
.
name
in
err
:
...
...
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