mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 22:30:22 -07:00
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
This commit is contained in:
parent
7900319fc3
commit
e0e1d3b561
1 changed files with 25 additions and 2 deletions
|
@ -39,6 +39,11 @@ notes:
|
||||||
requirements:
|
requirements:
|
||||||
- bigsuds
|
- bigsuds
|
||||||
options:
|
options:
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- Specifies descriptive text that identifies the pool.
|
||||||
|
required: false
|
||||||
|
version_added: "2.3"
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Pool/pool member state
|
- 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])
|
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():
|
def main():
|
||||||
lb_method_choices = ['round_robin', 'ratio_member',
|
lb_method_choices = ['round_robin', 'ratio_member',
|
||||||
'least_connection_member', 'observed_member',
|
'least_connection_member', 'observed_member',
|
||||||
|
@ -377,7 +392,8 @@ def main():
|
||||||
reselect_tries=dict(type='int'),
|
reselect_tries=dict(type='int'),
|
||||||
service_down_action=dict(type='str', choices=service_down_choices),
|
service_down_action=dict(type='str', choices=service_down_choices),
|
||||||
host=dict(type='str', aliases=['address']),
|
host=dict(type='str', aliases=['address']),
|
||||||
port=dict(type='int')
|
port=dict(type='int'),
|
||||||
|
description=dict(type='str')
|
||||||
)
|
)
|
||||||
argument_spec.update(meta_args)
|
argument_spec.update(meta_args)
|
||||||
|
|
||||||
|
@ -401,6 +417,7 @@ def main():
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
partition = module.params['partition']
|
partition = module.params['partition']
|
||||||
validate_certs = module.params['validate_certs']
|
validate_certs = module.params['validate_certs']
|
||||||
|
description = module.params['description']
|
||||||
|
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
pool = fq_name(partition, name)
|
pool = fq_name(partition, name)
|
||||||
|
@ -415,7 +432,7 @@ def main():
|
||||||
if monitors:
|
if monitors:
|
||||||
monitors = []
|
monitors = []
|
||||||
for monitor in module.params['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']
|
slow_ramp_time = module.params['slow_ramp_time']
|
||||||
reselect_tries = module.params['reselect_tries']
|
reselect_tries = module.params['reselect_tries']
|
||||||
service_down_action = module.params['service_down_action']
|
service_down_action = module.params['service_down_action']
|
||||||
|
@ -514,6 +531,8 @@ def main():
|
||||||
set_action_on_service_down(api, pool, service_down_action)
|
set_action_on_service_down(api, pool, service_down_action)
|
||||||
if host and port:
|
if host and port:
|
||||||
add_pool_member(api, pool, address, port)
|
add_pool_member(api, pool, address, port)
|
||||||
|
if description:
|
||||||
|
set_description(api, pool, description)
|
||||||
else:
|
else:
|
||||||
# check-mode return value
|
# check-mode return value
|
||||||
result = {'changed': True}
|
result = {'changed': True}
|
||||||
|
@ -552,6 +571,10 @@ def main():
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
add_pool_member(api, pool, address, port)
|
add_pool_member(api, pool, address, port)
|
||||||
result = {'changed': True}
|
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:
|
except Exception as e:
|
||||||
module.fail_json(msg="received exception: %s" % e)
|
module.fail_json(msg="received exception: %s" % e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue