|
|
|
|
@ -8,11 +8,9 @@ from __future__ import absolute_import, division, print_function
|
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {
|
|
|
|
|
'status': ['preview'],
|
|
|
|
|
'supported_by': 'community',
|
|
|
|
|
'metadata_version': '1.1'
|
|
|
|
|
}
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
|
'status': ['preview'],
|
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
|
---
|
|
|
|
|
@ -240,9 +238,9 @@ class Parameters(AnsibleF5Parameters):
|
|
|
|
|
for returnable in self.returnables:
|
|
|
|
|
result[returnable] = getattr(self, returnable)
|
|
|
|
|
result = self._filter_params(result)
|
|
|
|
|
return result
|
|
|
|
|
except Exception:
|
|
|
|
|
return result
|
|
|
|
|
pass
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def api_params(self):
|
|
|
|
|
result = {}
|
|
|
|
|
@ -254,14 +252,6 @@ class Parameters(AnsibleF5Parameters):
|
|
|
|
|
result = self._filter_params(result)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def username(self):
|
|
|
|
|
return self._values['target_username']
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def password(self):
|
|
|
|
|
return self._values['target_password']
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def destination(self):
|
|
|
|
|
if self.ip is None and self.port is None:
|
|
|
|
|
@ -337,6 +327,18 @@ class Parameters(AnsibleF5Parameters):
|
|
|
|
|
def type(self):
|
|
|
|
|
return 'http'
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def username(self):
|
|
|
|
|
return self._values['target_username']
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def password(self):
|
|
|
|
|
return self._values['target_password']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Changes(Parameters):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Difference(object):
|
|
|
|
|
def __init__(self, want, have=None):
|
|
|
|
|
@ -410,7 +412,7 @@ class ModuleManager(object):
|
|
|
|
|
self.client = client
|
|
|
|
|
self.have = None
|
|
|
|
|
self.want = Parameters(self.client.module.params)
|
|
|
|
|
self.changes = Parameters()
|
|
|
|
|
self.changes = Changes()
|
|
|
|
|
|
|
|
|
|
def _set_changed_options(self):
|
|
|
|
|
changed = {}
|
|
|
|
|
@ -418,7 +420,7 @@ class ModuleManager(object):
|
|
|
|
|
if getattr(self.want, key) is not None:
|
|
|
|
|
changed[key] = getattr(self.want, key)
|
|
|
|
|
if changed:
|
|
|
|
|
self.changes = Parameters(changed)
|
|
|
|
|
self.changes = Changes(changed)
|
|
|
|
|
|
|
|
|
|
def _update_changed_options(self):
|
|
|
|
|
diff = Difference(self.want, self.have)
|
|
|
|
|
@ -429,9 +431,12 @@ class ModuleManager(object):
|
|
|
|
|
if change is None:
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
changed[k] = change
|
|
|
|
|
if isinstance(change, dict):
|
|
|
|
|
changed.update(change)
|
|
|
|
|
else:
|
|
|
|
|
changed[k] = change
|
|
|
|
|
if changed:
|
|
|
|
|
self.changes = Parameters(changed)
|
|
|
|
|
self.changes = Changes(changed)
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
@ -584,6 +589,16 @@ class ArgumentSpec(object):
|
|
|
|
|
self.f5_product_name = 'bigip'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup_tokens(client):
|
|
|
|
|
try:
|
|
|
|
|
resource = client.api.shared.authz.tokens_s.token.load(
|
|
|
|
|
name=client.api.icrs.token
|
|
|
|
|
)
|
|
|
|
|
resource.delete()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
spec = ArgumentSpec()
|
|
|
|
|
|
|
|
|
|
@ -592,6 +607,7 @@ def main():
|
|
|
|
|
supports_check_mode=spec.supports_check_mode,
|
|
|
|
|
f5_product_name=spec.f5_product_name
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if not HAS_F5SDK:
|
|
|
|
|
raise F5ModuleError("The python f5-sdk module is required")
|
|
|
|
|
@ -601,8 +617,10 @@ def main():
|
|
|
|
|
|
|
|
|
|
mm = ModuleManager(client)
|
|
|
|
|
results = mm.exec_module()
|
|
|
|
|
cleanup_tokens(client)
|
|
|
|
|
client.module.exit_json(**results)
|
|
|
|
|
except F5ModuleError as e:
|
|
|
|
|
cleanup_tokens(client)
|
|
|
|
|
client.module.fail_json(msg=str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|