mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
Adds token cleanup to bigip irules (#34203)
Token cleanup helps keep the bigip from getting wedged
This commit is contained in:
parent
5bd8a8f491
commit
554ffd70f5
1 changed files with 17 additions and 5 deletions
|
@ -403,24 +403,36 @@ class ArgumentSpec(object):
|
||||||
self.f5_product_name = 'bigip'
|
self.f5_product_name = 'bigip'
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def cleanup_tokens(client):
|
||||||
if not HAS_F5SDK:
|
try:
|
||||||
raise F5ModuleError("The python f5-sdk module is required")
|
resource = client.api.shared.authz.tokens_s.token.load(
|
||||||
|
name=client.api.icrs.token
|
||||||
|
)
|
||||||
|
resource.delete()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
spec = ArgumentSpec()
|
spec = ArgumentSpec()
|
||||||
|
|
||||||
client = AnsibleF5Client(
|
client = AnsibleF5Client(
|
||||||
argument_spec=spec.argument_spec,
|
argument_spec=spec.argument_spec,
|
||||||
mutually_exclusive=spec.mutually_exclusive,
|
|
||||||
supports_check_mode=spec.supports_check_mode,
|
supports_check_mode=spec.supports_check_mode,
|
||||||
f5_product_name=spec.f5_product_name
|
f5_product_name=spec.f5_product_name,
|
||||||
|
mutually_exclusive=spec.mutually_exclusive,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if not HAS_F5SDK:
|
||||||
|
raise F5ModuleError("The python f5-sdk module is required")
|
||||||
|
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
client.module.exit_json(**results)
|
client.module.exit_json(**results)
|
||||||
except F5ModuleError as e:
|
except F5ModuleError as e:
|
||||||
|
cleanup_tokens(client)
|
||||||
client.module.fail_json(msg=str(e))
|
client.module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue