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
b93df1fc
Commit
b93df1fc
authored
Aug 30, 2012
by
Matt Wright
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update handling of state changes
parent
bdfccbfb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
library/supervisorctl
+19
-3
No files found.
library/supervisorctl
View file @
b93df1fc
...
@@ -27,6 +27,9 @@ def _find_supervisorctl():
...
@@ -27,6 +27,9 @@ def _find_supervisorctl():
if
os
.
path
.
exists
(
e
):
if
os
.
path
.
exists
(
e
):
return
e
return
e
def
_is_present
(
name
):
rc
,
out
,
err
=
_run
(
'
%
s status'
%
_find_supervisorctl
())
return
name
in
out
def
_is_running
(
name
):
def
_is_running
(
name
):
rc
,
out
,
err
=
_run
(
'
%
s status
%
s'
%
(
_find_supervisorctl
(),
name
))
rc
,
out
,
err
=
_run
(
'
%
s status
%
s'
%
(
_find_supervisorctl
(),
name
))
...
@@ -44,7 +47,7 @@ def _run(cmd):
...
@@ -44,7 +47,7 @@ def _run(cmd):
def
main
():
def
main
():
arg_spec
=
dict
(
arg_spec
=
dict
(
name
=
dict
(
required
=
True
),
name
=
dict
(
required
=
True
),
state
=
dict
(
required
=
True
,
choices
=
[
'started'
,
'restarted'
,
'stopped'
])
state
=
dict
(
required
=
True
,
choices
=
[
'
present'
,
'
started'
,
'restarted'
,
'stopped'
])
)
)
module
=
AnsibleModule
(
argument_spec
=
arg_spec
)
module
=
AnsibleModule
(
argument_spec
=
arg_spec
)
...
@@ -57,6 +60,20 @@ def main():
...
@@ -57,6 +60,20 @@ def main():
if
SUPERVISORCTL
is
None
:
if
SUPERVISORCTL
is
None
:
module
.
fail_json
(
msg
=
'supervisorctl is not installed'
)
module
.
fail_json
(
msg
=
'supervisorctl is not installed'
)
present
=
_is_present
(
name
)
if
state
==
'present'
:
if
not
present
:
_run
(
'
%
s reread'
%
SUPERVISORCTL
)
rc
,
out
,
err
=
_run
(
'
%
s add
%
s'
%
(
SUPERVISORCTL
,
name
))
if
'
%
s: added process group'
%
name
in
out
:
module
.
exit_json
(
changed
=
True
,
name
=
name
,
state
=
state
)
else
:
module
.
fail_json
(
msg
=
out
,
name
=
name
,
state
=
state
)
module
.
exit_json
(
changed
=
False
,
name
=
name
,
state
=
state
)
running
=
_is_running
(
name
)
running
=
_is_running
(
name
)
if
running
and
state
==
'started'
:
if
running
and
state
==
'started'
:
...
@@ -71,7 +88,7 @@ def main():
...
@@ -71,7 +88,7 @@ def main():
module
.
fail_json
(
msg
=
out
)
module
.
fail_json
(
msg
=
out
)
elif
running
and
state
==
'restarted'
:
elif
running
and
state
==
'restarted'
:
rc
,
out
,
err
=
_run
(
'
%
s update
'
%
SUPERVISORCTL
)
rc
,
out
,
err
=
_run
(
'
%
s update
%
s'
%
(
SUPERVISORCTL
,
name
)
)
rc
,
out
,
err
=
_run
(
'
%
s restart
%
s'
%
(
SUPERVISORCTL
,
name
))
rc
,
out
,
err
=
_run
(
'
%
s restart
%
s'
%
(
SUPERVISORCTL
,
name
))
if
'
%
s: stopped'
%
name
in
out
and
'
%
s: started'
%
name
in
out
:
if
'
%
s: stopped'
%
name
in
out
and
'
%
s: started'
%
name
in
out
:
...
@@ -80,7 +97,6 @@ def main():
...
@@ -80,7 +97,6 @@ def main():
module
.
fail_json
(
msg
=
out
)
module
.
fail_json
(
msg
=
out
)
elif
not
running
and
state
==
'started'
:
elif
not
running
and
state
==
'started'
:
rc
,
out
,
err
=
_run
(
'
%
s update'
%
SUPERVISORCTL
)
rc
,
out
,
err
=
_run
(
'
%
s start
%
s'
%
(
SUPERVISORCTL
,
name
))
rc
,
out
,
err
=
_run
(
'
%
s start
%
s'
%
(
SUPERVISORCTL
,
name
))
if
'
%
s: started'
%
name
in
out
:
if
'
%
s: started'
%
name
in
out
:
...
...
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