mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 12:44:22 -07:00
nagios: make services param a list
This commit is contained in:
parent
a692888478
commit
ea459fbc5e
1 changed files with 8 additions and 10 deletions
|
@ -90,7 +90,8 @@ options:
|
||||||
services running on it.) To schedule downtime for all O(services) on particular host use keyword V(all), for example
|
services running on it.) To schedule downtime for all O(services) on particular host use keyword V(all), for example
|
||||||
O(services=all).
|
O(services=all).
|
||||||
aliases: ["service"]
|
aliases: ["service"]
|
||||||
type: str
|
type: list
|
||||||
|
elements: str
|
||||||
servicegroup:
|
servicegroup:
|
||||||
description:
|
description:
|
||||||
- The Servicegroup we want to set downtimes/alerts for.
|
- The Servicegroup we want to set downtimes/alerts for.
|
||||||
|
@ -324,7 +325,7 @@ def main():
|
||||||
start=dict(type='str'),
|
start=dict(type='str'),
|
||||||
minutes=dict(type='int', default=30),
|
minutes=dict(type='int', default=30),
|
||||||
cmdfile=dict(type='str', default=which_cmdfile()),
|
cmdfile=dict(type='str', default=which_cmdfile()),
|
||||||
services=dict(type='str', aliases=['service']),
|
services=dict(type='list', elements='str', aliases=['service']),
|
||||||
command=dict(type='str'),
|
command=dict(type='str'),
|
||||||
),
|
),
|
||||||
required_if=[
|
required_if=[
|
||||||
|
@ -382,10 +383,12 @@ class Nagios(object):
|
||||||
self.cmdfile = kwargs['cmdfile']
|
self.cmdfile = kwargs['cmdfile']
|
||||||
self.command = kwargs['command']
|
self.command = kwargs['command']
|
||||||
|
|
||||||
if (kwargs['services'] is None) or (kwargs['services'] == 'host') or (kwargs['services'] == 'all'):
|
if kwargs['services'] is None :
|
||||||
self.services = kwargs['services']
|
self.services = kwargs['services']
|
||||||
|
elif len(kwargs['services']) == 1 and kwargs['services'][0] in ['host', 'all']:
|
||||||
|
self.services = kwargs['services'][0]
|
||||||
else:
|
else:
|
||||||
self.services = kwargs['services'].split(',')
|
self.services = kwargs['services']
|
||||||
|
|
||||||
self.command_results = []
|
self.command_results = []
|
||||||
|
|
||||||
|
@ -1243,14 +1246,9 @@ class Nagios(object):
|
||||||
elif self.action == 'unsilence_nagios':
|
elif self.action == 'unsilence_nagios':
|
||||||
self.unsilence_nagios()
|
self.unsilence_nagios()
|
||||||
|
|
||||||
elif self.action == 'command':
|
else: # self.action == 'command'
|
||||||
self.nagios_cmd(self.command)
|
self.nagios_cmd(self.command)
|
||||||
|
|
||||||
# wtf?
|
|
||||||
else:
|
|
||||||
self.module.fail_json(msg="unknown action specified: '%s'" %
|
|
||||||
self.action)
|
|
||||||
|
|
||||||
self.module.exit_json(nagios_commands=self.command_results,
|
self.module.exit_json(nagios_commands=self.command_results,
|
||||||
changed=True)
|
changed=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue