Adds server port argument to legacy modules (#2444)

This patch adds support for the server_port module. It
additionally updates the documentation in the module for
it.

The changes were tested in the f5-ansible repository to
ensure no breaking changes were made. This argument allows
modules to be used on BIG-IPs that are listening on
non-standard ports.
pull/18777/head
Tim Rupp 9 years ago committed by Matt Clay
parent 890366b67a
commit 1eb7aa5d78

@ -25,7 +25,9 @@ short_description: "Collect facts from F5 BIG-IP devices"
description:
- "Collect facts from F5 BIG-IP devices via iControl SOAP API"
version_added: "1.6"
author: "Matt Hite (@mhite)"
author:
- Matt Hite (@mhite)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11.4"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -42,6 +44,12 @@ options:
default: null
choices: []
aliases: []
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -137,8 +145,8 @@ class F5(object):
api: iControl API instance.
"""
def __init__(self, host, user, password, session=False, validate_certs=True):
self.api = bigip_api(host, user, password, validate_certs)
def __init__(self, host, user, password, session=False, validate_certs=True, port=443):
self.api = bigip_api(host, user, password, validate_certs, port)
if session:
self.start_session()
@ -1593,6 +1601,7 @@ def main():
module.fail_json(msg="the python suds and bigsuds modules are required")
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
validate_certs = module.params['validate_certs']
@ -1622,7 +1631,7 @@ def main():
facts = {}
if len(include) > 0:
f5 = F5(server, user, password, session, validate_certs)
f5 = F5(server, user, password, session, validate_certs, server_port)
saved_active_folder = f5.get_active_folder()
saved_recursive_query_state = f5.get_recursive_query_state()
if saved_active_folder != "/":

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP GTM virtual servers"
description:
- "Manages F5 BIG-IP GTM virtual servers"
version_added: "2.2"
author: 'Michael Perzel'
author:
- Michael Perzel (@perzizzle)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11.4"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -39,6 +41,11 @@ options:
description:
- BIG-IP host
required: true
server_port:
description:
- BIG-IP server port
required: false
default: 443
user:
description:
- BIG-IP username
@ -96,11 +103,6 @@ else:
bigsuds_found = True
def bigip_api(server, user, password):
api = bigsuds.BIGIP(hostname=server, username=user, password=password)
return api
def server_exists(api, server):
# hack to determine if virtual server exists
result = False
@ -157,17 +159,19 @@ def set_virtual_server_state(api, name, server, state):
def main():
argument_spec = f5_argument_spec()
meta_args = dict(
state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
host=dict(type='str', default=None, aliases=['address']),
port=dict(type='int', default=None),
virtual_server_name=dict(type='str', required=True),
virtual_server_server=dict(type='str', required=True)
)
argument_spec.update(meta_args)
module = AnsibleModule(
argument_spec=dict(
server=dict(type='str', required=True),
user=dict(type='str', required=True),
password=dict(type='str', required=True, no_log=True),
state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
host=dict(type='str', default=None, aliases=['address']),
port=dict(type='int', default=None),
virtual_server_name=dict(type='str', required=True),
virtual_server_server=dict(type='str', required=True)
),
argument_spec=argument_spec,
supports_check_mode=True
)
@ -175,6 +179,8 @@ def main():
module.fail_json(msg="the python bigsuds module is required")
server = module.params['server']
server_port = module.params['server_port']
validate_certs = module.params['validate_certs']
user = module.params['user']
password = module.params['password']
virtual_server_name = module.params['virtual_server_name']
@ -186,7 +192,7 @@ def main():
result = {'changed': False} # default
try:
api = bigip_api(server, user, password)
api = bigip_api(server, user, password, validate_certs, port=server_port)
if state == 'absent':
if virtual_server_exists(api, virtual_server_name, virtual_server_server):
@ -239,6 +245,7 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.f5 import *
if __name__ == '__main__':
main()

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP GTM wide ip"
description:
- "Manages F5 BIG-IP GTM wide ip"
version_added: "2.0"
author: 'Michael Perzel'
author:
- Michael Perzel (@perzizzle)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11.4"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -39,6 +41,12 @@ options:
description:
- BIG-IP host
required: true
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -56,6 +64,13 @@ options:
'vs_capacity', 'least_conn', 'lowest_rtt', 'lowest_hops',
'packet_rate', 'cpu', 'hit_ratio', 'qos', 'bps',
'drop_packet', 'explicit_ip', 'connection_rate', 'vs_score']
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be
used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.2"
wide_ip:
description:
- Wide IP name
@ -80,10 +95,6 @@ except ImportError:
else:
bigsuds_found = True
def bigip_api(server, user, password):
api = bigsuds.BIGIP(hostname=server, username=user, password=password)
return api
def get_wide_ip_lb_method(api, wide_ip):
lb_method = api.GlobalLB.WideIP.get_lb_method(wide_ips=[wide_ip])[0]
lb_method = lb_method.strip().replace('LB_METHOD_', '').lower()
@ -114,21 +125,21 @@ def set_wide_ip_lb_method(api, wide_ip, lb_method):
api.GlobalLB.WideIP.set_lb_method(wide_ips=[wide_ip], lb_methods=[lb_method])
def main():
argument_spec = f5_argument_spec()
lb_method_choices = ['return_to_dns', 'null', 'round_robin',
'ratio', 'topology', 'static_persist', 'global_availability',
'vs_capacity', 'least_conn', 'lowest_rtt', 'lowest_hops',
'packet_rate', 'cpu', 'hit_ratio', 'qos', 'bps',
'drop_packet', 'explicit_ip', 'connection_rate', 'vs_score']
meta_args = dict(
lb_method = dict(type='str', required=True, choices=lb_method_choices),
wide_ip = dict(type='str', required=True)
)
argument_spec.update(meta_args)
module = AnsibleModule(
argument_spec = dict(
server = dict(type='str', required=True),
user = dict(type='str', required=True),
password = dict(type='str', required=True),
lb_method = dict(type='str', required=True, choices=lb_method_choices),
wide_ip = dict(type='str', required=True)
),
argument_spec=argument_spec,
supports_check_mode=True
)
@ -136,15 +147,17 @@ def main():
module.fail_json(msg="the python bigsuds module is required")
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
wide_ip = module.params['wide_ip']
lb_method = module.params['lb_method']
validate_certs = module.params['validate_certs']
result = {'changed': False} # default
try:
api = bigip_api(server, user, password)
api = bigip_api(server, user, password, validate_certs, port=server_port)
if not wide_ip_exists(api, wide_ip):
module.fail_json(msg="wide ip %s does not exist" % wide_ip)
@ -163,6 +176,7 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.f5 import *
if __name__ == '__main__':
main()

@ -27,7 +27,9 @@ short_description: "Manages F5 BIG-IP LTM http monitors"
description:
- "Manages F5 BIG-IP LTM monitors via iControl SOAP API"
version_added: "1.4"
author: "Serge van Ginderachter (@srvg)"
author:
- Serge van Ginderachter (@srvg)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -41,6 +43,12 @@ options:
- BIG-IP host
required: true
default: null
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -326,6 +334,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -347,7 +356,7 @@ def main():
# end monitor specific stuff
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
monitor_exists = check_monitor_exists(module, api, monitor, parent)

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP LTM tcp monitors"
description:
- "Manages F5 BIG-IP LTM tcp monitors via iControl SOAP API"
version_added: "1.4"
author: "Serge van Ginderachter (@srvg)"
author:
- Serge van Ginderachter (@srvg)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -39,6 +41,12 @@ options:
- BIG-IP host
required: true
default: null
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -345,6 +353,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -370,7 +379,7 @@ def main():
# end monitor specific stuff
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
monitor_exists = check_monitor_exists(module, api, monitor, parent)

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP LTM nodes"
description:
- "Manages F5 BIG-IP LTM nodes via iControl SOAP API"
version_added: "1.4"
author: "Matt Hite (@mhite)"
author:
- Matt Hite (@mhite)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -40,6 +42,12 @@ options:
default: null
choices: []
aliases: []
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -313,7 +321,8 @@ def set_monitors(api, name, monitor_type, quorum, monitor_templates):
def main():
monitor_type_choices = ['and_list', 'm_of_n']
argument_spec=f5_argument_spec()
argument_spec = f5_argument_spec()
argument_spec.update(dict(
session_state = dict(type='str', choices=['enabled', 'disabled']),
monitor_state = dict(type='str', choices=['enabled', 'disabled']),
@ -340,6 +349,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -387,7 +397,7 @@ def main():
module.fail_json(msg="quorum requires monitors parameter")
try:
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
result = {'changed': False} # default
if state == 'absent':

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP LTM pools"
description:
- "Manages F5 BIG-IP LTM pools via iControl SOAP API"
version_added: "1.2"
author: "Matt Hite (@mhite)"
author:
- Matt Hite (@mhite)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -40,6 +42,12 @@ options:
default: null
choices: []
aliases: []
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -95,7 +103,7 @@ options:
'least_connection_node_address', 'fastest_node_address',
'observed_node_address', 'predictive_node_address',
'dynamic_ratio', 'fastest_app_response', 'least_sessions',
'dynamic_ratio_member', 'l3_addr', 'unknown',
'dynamic_ratio_member', 'l3_addr',
'weighted_least_connection_member',
'weighted_least_connection_node_address',
'ratio_session', 'ratio_least_connection_member',
@ -353,7 +361,7 @@ def main():
'fastest_node_address', 'observed_node_address',
'predictive_node_address', 'dynamic_ratio',
'fastest_app_response', 'least_sessions',
'dynamic_ratio_member', 'l3_addr', 'unknown',
'dynamic_ratio_member', 'l3_addr',
'weighted_least_connection_member',
'weighted_least_connection_node_address',
'ratio_session', 'ratio_least_connection_member',
@ -392,6 +400,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -449,7 +458,7 @@ def main():
module.fail_json(msg="quorum requires monitors parameter")
try:
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
result = {'changed': False} # default
if state == 'absent':

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP LTM pool members"
description:
- "Manages F5 BIG-IP LTM pool members via iControl SOAP API"
version_added: "1.4"
author: "Matt Hite (@mhite)"
author:
- Matt Hite (@mhite)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -39,9 +41,12 @@ options:
description:
- BIG-IP host
required: true
default: null
choices: []
aliases: []
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -371,6 +376,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -399,7 +405,7 @@ def main():
module.fail_json(msg="valid ports must be in range 0 - 65535")
try:
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
if not pool_exists(api, pool):
module.fail_json(msg="pool %s does not exist" % pool)
result = {'changed': False} # default

@ -25,7 +25,9 @@ short_description: "Manages F5 BIG-IP LTM virtual servers"
description:
- "Manages F5 BIG-IP LTM virtual servers via iControl SOAP API"
version_added: "2.1"
author: Etienne Carriere (@Etienne-Carriere)
author:
- Etienne Carriere (@Etienne-Carriere)
- Tim Rupp (@caphrim007)
notes:
- "Requires BIG-IP software version >= 11"
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
@ -37,9 +39,12 @@ options:
description:
- BIG-IP host
required: true
default: null
choices: []
aliases: []
server_port:
description:
- BIG-IP server port
required: false
default: 443
version_added: "2.2"
user:
description:
- BIG-IP username
@ -165,7 +170,7 @@ EXAMPLES = '''
name: myvirtualserver
port: 8080
- name: Delete pool
- name: Delete virtual server
local_action:
module: bigip_virtual_server
server: lb.mydomain.net
@ -437,6 +442,7 @@ def main():
module.fail_json(msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task')
server = module.params['server']
server_port = module.params['server_port']
user = module.params['user']
password = module.params['password']
state = module.params['state']
@ -457,7 +463,7 @@ def main():
module.fail_json(msg="valid ports must be in range 1 - 65535")
try:
api = bigip_api(server, user, password, validate_certs)
api = bigip_api(server, user, password, validate_certs, port=server_port)
result = {'changed': False} # default
if state == 'absent':

Loading…
Cancel
Save