@ -65,6 +65,7 @@ options:
description :
description :
- Minutes to schedule downtime for .
- Minutes to schedule downtime for .
- Only usable with the C ( downtime ) action .
- Only usable with the C ( downtime ) action .
type : int
default : 30
default : 30
services :
services :
description :
description :
@ -193,7 +194,6 @@ EXAMPLES = '''
command : DISABLE_FAILURE_PREDICTION
command : DISABLE_FAILURE_PREDICTION
'''
'''
import types
import time
import time
import os . path
import os . path
import stat
import stat
@ -271,7 +271,6 @@ def main():
action = module . params [ ' action ' ]
action = module . params [ ' action ' ]
host = module . params [ ' host ' ]
host = module . params [ ' host ' ]
servicegroup = module . params [ ' servicegroup ' ]
servicegroup = module . params [ ' servicegroup ' ]
minutes = module . params [ ' minutes ' ]
services = module . params [ ' services ' ]
services = module . params [ ' services ' ]
cmdfile = module . params [ ' cmdfile ' ]
cmdfile = module . params [ ' cmdfile ' ]
command = module . params [ ' command ' ]
command = module . params [ ' command ' ]
@ -284,7 +283,7 @@ def main():
# command = command
# command = command
#
#
# AnsibleModule will verify most stuff, we need to verify
# AnsibleModule will verify most stuff, we need to verify
# ' minutes' and ' service' manually.
# ' service' manually.
##################################################################
##################################################################
if action not in [ ' command ' , ' silence_nagios ' , ' unsilence_nagios ' ] :
if action not in [ ' command ' , ' silence_nagios ' , ' unsilence_nagios ' ] :
@ -295,13 +294,6 @@ def main():
# Make sure there's an actual service selected
# Make sure there's an actual service selected
if not services :
if not services :
module . fail_json ( msg = ' no service selected to set downtime for ' )
module . fail_json ( msg = ' no service selected to set downtime for ' )
# Make sure minutes is a number
try :
m = int ( minutes )
if not isinstance ( m , types . IntType ) :
module . fail_json ( msg = ' minutes must be a number ' )
except Exception :
module . fail_json ( msg = ' invalid entry for minutes ' )
######################################################################
######################################################################
if action == ' delete_downtime ' :
if action == ' delete_downtime ' :
@ -315,13 +307,6 @@ def main():
# Make sure there's an actual servicegroup selected
# Make sure there's an actual servicegroup selected
if not servicegroup :
if not servicegroup :
module . fail_json ( msg = ' no servicegroup selected to set downtime for ' )
module . fail_json ( msg = ' no servicegroup selected to set downtime for ' )
# Make sure minutes is a number
try :
m = int ( minutes )
if not isinstance ( m , types . IntType ) :
module . fail_json ( msg = ' minutes must be a number ' )
except Exception :
module . fail_json ( msg = ' invalid entry for minutes ' )
##################################################################
##################################################################
if action in [ ' enable_alerts ' , ' disable_alerts ' ] :
if action in [ ' enable_alerts ' , ' disable_alerts ' ] :
@ -367,7 +352,7 @@ class Nagios(object):
self . comment = kwargs [ ' comment ' ]
self . comment = kwargs [ ' comment ' ]
self . host = kwargs [ ' host ' ]
self . host = kwargs [ ' host ' ]
self . servicegroup = kwargs [ ' servicegroup ' ]
self . servicegroup = kwargs [ ' servicegroup ' ]
self . minutes = int ( kwargs [ ' minutes ' ] )
self . minutes = kwargs [ ' minutes ' ]
self . cmdfile = kwargs [ ' cmdfile ' ]
self . cmdfile = kwargs [ ' cmdfile ' ]
self . command = kwargs [ ' command ' ]
self . command = kwargs [ ' command ' ]