mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
svc: Add kill command (svc -k)
This commit is contained in:
parent
88fea228dc
commit
56ecf602dc
1 changed files with 9 additions and 2 deletions
|
@ -20,7 +20,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
|
||||||
svc (svc -t). C(reloaded) will send a sigusr1 (svc -u).
|
svc (svc -t) and C(killed) will always bounce the svc (svc -k).
|
||||||
|
C(reloaded) will send a sigusr1 (svc -u).
|
||||||
C(once) will run a normally downed svc once (svc -o), not really
|
C(once) will run a normally downed svc once (svc -o), not really
|
||||||
an idempotent operation.
|
an idempotent operation.
|
||||||
downed:
|
downed:
|
||||||
|
@ -54,6 +55,9 @@ EXAMPLES = '''
|
||||||
# Example action to stop svc dnscache, if running
|
# Example action to stop svc dnscache, if running
|
||||||
- svc: name=dnscache state=stopped
|
- svc: name=dnscache state=stopped
|
||||||
|
|
||||||
|
# Example action to kill svc dnscache, in all cases
|
||||||
|
- svc : name=dnscache state=killed
|
||||||
|
|
||||||
# Example action to restart svc dnscache, in all cases
|
# Example action to restart svc dnscache, in all cases
|
||||||
- svc : name=dnscache state=restarted
|
- svc : name=dnscache state=restarted
|
||||||
|
|
||||||
|
@ -194,6 +198,9 @@ class Svc(object):
|
||||||
def restart(self):
|
def restart(self):
|
||||||
return self.execute_command([self.svc_cmd, '-t', self.svc_full])
|
return self.execute_command([self.svc_cmd, '-t', self.svc_full])
|
||||||
|
|
||||||
|
def kill(self):
|
||||||
|
return self.execute_command([self.svc_cmd, '-k', self.svc_full])
|
||||||
|
|
||||||
def execute_command(self, cmd):
|
def execute_command(self, cmd):
|
||||||
try:
|
try:
|
||||||
(rc, out, err) = self.module.run_command(' '.join(cmd))
|
(rc, out, err) = self.module.run_command(' '.join(cmd))
|
||||||
|
@ -215,7 +222,7 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
name = dict(required=True),
|
name = dict(required=True),
|
||||||
state = dict(choices=['started', 'stopped', 'restarted', 'reloaded', 'once']),
|
state = dict(choices=['started', 'stopped', 'restarted', 'killed', 'reloaded', 'once']),
|
||||||
enabled = dict(required=False, type='bool', choices=BOOLEANS),
|
enabled = dict(required=False, type='bool', choices=BOOLEANS),
|
||||||
downed = dict(required=False, type='bool', choices=BOOLEANS),
|
downed = dict(required=False, type='bool', choices=BOOLEANS),
|
||||||
dist = dict(required=False, default='daemontools'),
|
dist = dict(required=False, default='daemontools'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue