bigip_monitor_http: two small bug fixes
- extra properties were not set at creation, only when updating which can be overlooked when running the module from more than 1 node... - fix bas var as time_until_up didn't get used
This commit is contained in:
parent
320d41149a
commit
ad6ffe00d0
1 changed files with 20 additions and 22 deletions
|
@ -94,19 +94,19 @@ options:
|
||||||
required: true
|
required: true
|
||||||
default: none
|
default: none
|
||||||
ip:
|
ip:
|
||||||
description:
|
description:
|
||||||
- IP address part of the ipport definition. The default API setting
|
- IP address part of the ipport definition. The default API setting
|
||||||
is "0.0.0.0".
|
is "0.0.0.0".
|
||||||
required: false
|
required: false
|
||||||
default: none
|
default: none
|
||||||
port:
|
port:
|
||||||
description:
|
description:
|
||||||
- port address part op the ipport definition. Tyhe default API
|
- port address part op the ipport definition. Tyhe default API
|
||||||
setting is 0.
|
setting is 0.
|
||||||
required: false
|
required: false
|
||||||
default: none
|
default: none
|
||||||
interval:
|
interval:
|
||||||
description:
|
description:
|
||||||
- The interval specifying how frequently the monitor instance
|
- The interval specifying how frequently the monitor instance
|
||||||
of this template will run. By default, this interval is used for up and
|
of this template will run. By default, this interval is used for up and
|
||||||
down states. The default API setting is 5.
|
down states. The default API setting is 5.
|
||||||
|
@ -199,7 +199,7 @@ def check_monitor_exists(module, api, monitor, parent):
|
||||||
|
|
||||||
def create_monitor(api, monitor, template_attributes):
|
def create_monitor(api, monitor, template_attributes):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api.LocalLB.Monitor.create_template(templates=[{'template_name': monitor, 'template_type': TEMPLATE_TYPE}], template_attributes=[template_attributes])
|
api.LocalLB.Monitor.create_template(templates=[{'template_name': monitor, 'template_type': TEMPLATE_TYPE}], template_attributes=[template_attributes])
|
||||||
except bigsuds.OperationFailed, e:
|
except bigsuds.OperationFailed, e:
|
||||||
if "already exists" in str(e):
|
if "already exists" in str(e):
|
||||||
|
@ -282,7 +282,7 @@ def set_ipport(api, monitor, ipport):
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# main loop
|
# main loop
|
||||||
#
|
#
|
||||||
# writing a module for other monitor types should
|
# writing a module for other monitor types should
|
||||||
# only need an updated main() (and monitor specific functions)
|
# only need an updated main() (and monitor specific functions)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -345,19 +345,19 @@ def main():
|
||||||
if port is None:
|
if port is None:
|
||||||
port = cur_ipport['ipport']['port']
|
port = cur_ipport['ipport']['port']
|
||||||
else: # use API defaults if not defined to create it
|
else: # use API defaults if not defined to create it
|
||||||
if interval is None:
|
if interval is None:
|
||||||
interval = 5
|
interval = 5
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
timeout = 16
|
timeout = 16
|
||||||
if ip is None:
|
if ip is None:
|
||||||
ip = '0.0.0.0'
|
ip = '0.0.0.0'
|
||||||
if port is None:
|
if port is None:
|
||||||
port = 0
|
port = 0
|
||||||
if send is None:
|
if send is None:
|
||||||
send = ''
|
send = ''
|
||||||
if receive is None:
|
if receive is None:
|
||||||
receive = ''
|
receive = ''
|
||||||
if receive_disable is None:
|
if receive_disable is None:
|
||||||
receive_disable = ''
|
receive_disable = ''
|
||||||
|
|
||||||
# define and set address type
|
# define and set address type
|
||||||
|
@ -394,7 +394,7 @@ def main():
|
||||||
{'type': 'ITYPE_TIMEOUT',
|
{'type': 'ITYPE_TIMEOUT',
|
||||||
'value': timeout},
|
'value': timeout},
|
||||||
{'type': 'ITYPE_TIME_UNTIL_UP',
|
{'type': 'ITYPE_TIME_UNTIL_UP',
|
||||||
'value': interval}]
|
'value': time_until_up}]
|
||||||
|
|
||||||
# main logic, monitor generic
|
# main logic, monitor generic
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ def main():
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if monitor_exists:
|
if monitor_exists:
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
# possible race condition if same task
|
# possible race condition if same task
|
||||||
# on other node deleted it first
|
# on other node deleted it first
|
||||||
result['changed'] |= delete_monitor(api, monitor)
|
result['changed'] |= delete_monitor(api, monitor)
|
||||||
else:
|
else:
|
||||||
|
@ -414,26 +414,24 @@ def main():
|
||||||
else: # state present
|
else: # state present
|
||||||
## check for monitor itself
|
## check for monitor itself
|
||||||
if not monitor_exists: # create it
|
if not monitor_exists: # create it
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
# again, check changed status here b/c race conditions
|
# again, check changed status here b/c race conditions
|
||||||
# if other task already created it
|
# if other task already created it
|
||||||
result['changed'] |= create_monitor(api, monitor, template_attributes)
|
result['changed'] |= create_monitor(api, monitor, template_attributes)
|
||||||
else:
|
else:
|
||||||
result['changed'] |= True
|
result['changed'] |= True
|
||||||
|
|
||||||
## check for monitor parameters
|
## check for monitor parameters
|
||||||
# whether it already existed, or was just created, now update
|
# whether it already existed, or was just created, now update
|
||||||
# the update functions need to check for check mode but
|
# the update functions need to check for check mode but
|
||||||
# cannot update settings if it doesn't exist which happens in check mode
|
# cannot update settings if it doesn't exist which happens in check mode
|
||||||
if monitor_exists and not module.check_mode:
|
result['changed'] |= update_monitor_properties(api, module, monitor,
|
||||||
result['changed'] |= update_monitor_properties(api, module, monitor,
|
template_string_properties,
|
||||||
template_string_properties,
|
template_integer_properties)
|
||||||
template_integer_properties)
|
|
||||||
# else assume nothing changed
|
|
||||||
|
|
||||||
# we just have to update the ipport if monitor already exists and it's different
|
# we just have to update the ipport if monitor already exists and it's different
|
||||||
if monitor_exists and cur_ipport != ipport:
|
if monitor_exists and cur_ipport != ipport:
|
||||||
set_ipport(api, monitor, ipport)
|
set_ipport(api, monitor, ipport)
|
||||||
result['changed'] |= True
|
result['changed'] |= True
|
||||||
#else: monitor doesn't exist (check mode) or ipport is already ok
|
#else: monitor doesn't exist (check mode) or ipport is already ok
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue