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
7d1ff1bd
Commit
7d1ff1bd
authored
Apr 04, 2013
by
tin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the service module to terminate early if only changing the enabled state.
Expanded the documentation slightly.
parent
8d99ef71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
library/service
+21
-9
No files found.
library/service
View file @
7d1ff1bd
...
@@ -37,7 +37,8 @@ options:
...
@@ -37,7 +37,8 @@ options:
description:
description:
- C(started)/C(stopped) are idempotent actions that will not run
- C(started)/C(stopped) are idempotent actions that will not run
commands unless necessary. C(restarted) will always bounce the
commands unless necessary. C(restarted) will always bounce the
service. C(reloaded) will always reload.
service. C(reloaded) will always reload. At least one of state
and enabled are required.
pattern:
pattern:
required: false
required: false
version_added: "0.7"
version_added: "0.7"
...
@@ -50,7 +51,9 @@ options:
...
@@ -50,7 +51,9 @@ options:
required: false
required: false
choices: [ "yes", "no" ]
choices: [ "yes", "no" ]
description:
description:
- Whether the service should start on boot.
- Whether the service should start on boot. At least one of state and
enabled are required.
arguments:
arguments:
description:
description:
- Additional arguments provided on the command line
- Additional arguments provided on the command line
...
@@ -738,7 +741,7 @@ class SunOSService(Service):
...
@@ -738,7 +741,7 @@ class SunOSService(Service):
self
.
module
.
fail_json
(
msg
=
'unable to find svcs binary'
)
self
.
module
.
fail_json
(
msg
=
'unable to find svcs binary'
)
self
.
svcadm_cmd
=
self
.
module
.
get_bin_path
(
'svcadm'
,
True
)
self
.
svcadm_cmd
=
self
.
module
.
get_bin_path
(
'svcadm'
,
True
)
if
not
self
.
svcadm_cmd
:
if
not
self
.
svcadm_cmd
:
self
.
module
.
fail_json
(
msg
=
'unable to find svcadm binary'
)
self
.
module
.
fail_json
(
msg
=
'unable to find svcadm binary'
)
...
@@ -789,9 +792,9 @@ class SunOSService(Service):
...
@@ -789,9 +792,9 @@ class SunOSService(Service):
enabled
=
True
enabled
=
True
if
line
.
find
(
"temporary"
)
!=
-
1
:
if
line
.
find
(
"temporary"
)
!=
-
1
:
temporary
=
True
temporary
=
True
startup_enabled
=
(
enabled
and
not
temporary
)
or
(
not
enabled
and
temporary
)
startup_enabled
=
(
enabled
and
not
temporary
)
or
(
not
enabled
and
temporary
)
if
self
.
enable
and
startup_enabled
:
if
self
.
enable
and
startup_enabled
:
return
return
elif
(
not
self
.
enable
)
and
(
not
startup_enabled
):
elif
(
not
self
.
enable
)
and
(
not
startup_enabled
):
...
@@ -813,8 +816,8 @@ class SunOSService(Service):
...
@@ -813,8 +816,8 @@ class SunOSService(Service):
self
.
module
.
fail_json
(
msg
=
stdout
)
self
.
module
.
fail_json
(
msg
=
stdout
)
self
.
changed
=
True
self
.
changed
=
True
def
service_control
(
self
):
def
service_control
(
self
):
status
=
self
.
get_sunos_svcs_status
()
status
=
self
.
get_sunos_svcs_status
()
...
@@ -838,7 +841,7 @@ class SunOSService(Service):
...
@@ -838,7 +841,7 @@ class SunOSService(Service):
subcmd
=
"restart"
subcmd
=
"restart"
elif
self
.
action
==
'restart'
and
status
!=
'online'
:
elif
self
.
action
==
'restart'
and
status
!=
'online'
:
subcmd
=
"enable -rst"
subcmd
=
"enable -rst"
return
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
self
.
svcadm_cmd
,
subcmd
,
self
.
name
))
return
self
.
execute_command
(
"
%
s
%
s
%
s"
%
(
self
.
svcadm_cmd
,
subcmd
,
self
.
name
))
...
@@ -856,6 +859,8 @@ def main():
...
@@ -856,6 +859,8 @@ def main():
),
),
supports_check_mode
=
True
supports_check_mode
=
True
)
)
if
module
.
params
[
'state'
]
is
None
and
module
.
params
[
'enabled'
]
is
None
:
module
.
fail_json
(
msg
=
"Neither 'state' nor 'enabled' set"
)
service
=
Service
(
module
)
service
=
Service
(
module
)
...
@@ -870,7 +875,6 @@ def main():
...
@@ -870,7 +875,6 @@ def main():
err
=
''
err
=
''
result
=
{}
result
=
{}
result
[
'name'
]
=
service
.
name
result
[
'name'
]
=
service
.
name
result
[
'state'
]
=
service
.
state
# Find service management tools
# Find service management tools
service
.
get_service_tools
()
service
.
get_service_tools
()
...
@@ -880,6 +884,14 @@ def main():
...
@@ -880,6 +884,14 @@ def main():
# FIXME: ideally this should detect if we need to toggle the enablement state, though
# FIXME: ideally this should detect if we need to toggle the enablement state, though
# it's unlikely the changed handler would need to fire in this case so it's a minor thing.
# it's unlikely the changed handler would need to fire in this case so it's a minor thing.
service
.
service_enable
()
service
.
service_enable
()
result
[
'enabled'
]
=
service
.
enable
if
module
.
params
[
'state'
]
is
None
:
# Not changing the running state, so bail out now.
result
[
'changed'
]
=
service
.
changed
module
.
exit_json
(
**
result
)
result
[
'state'
]
=
service
.
state
# Collect service status
# Collect service status
if
service
.
pattern
:
if
service
.
pattern
:
...
...
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