From e0e1d3b5616aed8df2573b8368e9461637ccb20d Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Thu, 15 Dec 2016 13:28:30 -0800 Subject: [PATCH] Adds description parameter to pools (#19362) This patch adds the description parameter as a supported param of the bigip_pool module. Tests for this change are available here https://github.com/F5Networks/f5-ansible/blob/master/roles/bigip_pool/tasks/main.yaml#L732 --- lib/ansible/modules/network/f5/bigip_pool.py | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_pool.py b/lib/ansible/modules/network/f5/bigip_pool.py index eb6b8f3adaa..7c6b6265631 100644 --- a/lib/ansible/modules/network/f5/bigip_pool.py +++ b/lib/ansible/modules/network/f5/bigip_pool.py @@ -39,6 +39,11 @@ notes: requirements: - bigsuds options: + description: + description: + - Specifies descriptive text that identifies the pool. + required: false + version_added: "2.3" state: description: - Pool/pool member state @@ -347,6 +352,16 @@ def add_pool_member(api, pool, address, port): api.LocalLB.Pool.add_member_v2(pool_names=[pool], members=[members]) +def set_description(api, pool, description): + api.LocalLB.Pool.set_description( + pool_names=[pool], descriptions=[description] + ) + + +def get_description(api, pool): + return api.LocalLB.Pool.get_description(pool_names=[pool])[0] + + def main(): lb_method_choices = ['round_robin', 'ratio_member', 'least_connection_member', 'observed_member', @@ -377,7 +392,8 @@ def main(): reselect_tries=dict(type='int'), service_down_action=dict(type='str', choices=service_down_choices), host=dict(type='str', aliases=['address']), - port=dict(type='int') + port=dict(type='int'), + description=dict(type='str') ) argument_spec.update(meta_args) @@ -401,6 +417,7 @@ def main(): state = module.params['state'] partition = module.params['partition'] validate_certs = module.params['validate_certs'] + description = module.params['description'] name = module.params['name'] pool = fq_name(partition, name) @@ -415,7 +432,7 @@ def main(): if monitors: monitors = [] for monitor in module.params['monitors']: - monitors.append(fq_name(partition, monitor)) + monitors.append(fq_name(partition, monitor)) slow_ramp_time = module.params['slow_ramp_time'] reselect_tries = module.params['reselect_tries'] service_down_action = module.params['service_down_action'] @@ -514,6 +531,8 @@ def main(): set_action_on_service_down(api, pool, service_down_action) if host and port: add_pool_member(api, pool, address, port) + if description: + set_description(api, pool, description) else: # check-mode return value result = {'changed': True} @@ -552,6 +571,10 @@ def main(): if not module.check_mode: add_pool_member(api, pool, address, port) result = {'changed': True} + if description and description != get_description(api, pool): + if not module.check_mode: + set_description(api, pool, description) + result = {'changed': True} except Exception as e: module.fail_json(msg="received exception: %s" % e)