diff --git a/lib/ansible/module_utils/network/f5/bigiq.py b/lib/ansible/module_utils/network/f5/bigiq.py index f994ed6f43..bc1bac413d 100644 --- a/lib/ansible/module_utils/network/f5/bigiq.py +++ b/lib/ansible/module_utils/network/f5/bigiq.py @@ -8,7 +8,6 @@ __metaclass__ = type import os -import time try: diff --git a/lib/ansible/module_utils/network/f5/icontrol.py b/lib/ansible/module_utils/network/f5/icontrol.py index 43f8db7e86..7f8e294a3b 100644 --- a/lib/ansible/module_utils/network/f5/icontrol.py +++ b/lib/ansible/module_utils/network/f5/icontrol.py @@ -14,9 +14,13 @@ try: except ImportError: from io import StringIO +try: + from BytesIO import BytesIO +except ImportError: + from io import BytesIO + from ansible.module_utils.urls import urlparse from ansible.module_utils.urls import generic_urlparse -from ansible.module_utils._text import to_native from ansible.module_utils.urls import Request try: @@ -392,7 +396,7 @@ def upload_file(client, url, src, dest=None): Raises: F5ModuleError: Raised if ``retries`` limit is exceeded. """ - if isinstance(src, StringIO): + if isinstance(src, StringIO) or isinstance(src, BytesIO): fileobj = src else: fileobj = open(src, 'rb') diff --git a/lib/ansible/modules/network/f5/bigip_iapplx_package.py b/lib/ansible/modules/network/f5/bigip_iapplx_package.py index d868807cc2..e9269cb944 100644 --- a/lib/ansible/modules/network/f5/bigip_iapplx_package.py +++ b/lib/ansible/modules/network/f5/bigip_iapplx_package.py @@ -330,7 +330,7 @@ class ModuleManager(object): raise F5ModuleError(resp.content) return response - def upload_to_device(self,): + def upload_to_device(self): url = 'https://{0}:{1}/mgmt/shared/file-transfer/uploads'.format( self.client.provider['server'], self.client.provider['server_port'] diff --git a/lib/ansible/modules/network/f5/bigip_monitor_dns.py b/lib/ansible/modules/network/f5/bigip_monitor_dns.py index 97a90e9423..e74c04d3a5 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_dns.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_dns.py @@ -279,10 +279,10 @@ allowed_divergence_value: type: int sample: 25 description: - description: The description of the monitor. - returned: changed - type: str - sample: Important Monitor + description: The description of the monitor. + returned: changed + type: str + sample: Important Monitor adaptive_limit: description: Absolute number of milliseconds that may not be exceeded by a monitor probe. returned: changed diff --git a/lib/ansible/modules/network/f5/bigip_profile_fastl4.py b/lib/ansible/modules/network/f5/bigip_profile_fastl4.py index f47d4a46a7..a0a629b83c 100644 --- a/lib/ansible/modules/network/f5/bigip_profile_fastl4.py +++ b/lib/ansible/modules/network/f5/bigip_profile_fastl4.py @@ -553,7 +553,7 @@ class Parameters(AnsibleF5Parameters): ] returnables = [ - 'client_timeout' + 'client_timeout', 'description', 'explicit_flow_migration', 'idle_timeout', diff --git a/lib/ansible/modules/network/f5/bigip_remote_role.py b/lib/ansible/modules/network/f5/bigip_remote_role.py index 25ceee668a..5ccb52ea3d 100644 --- a/lib/ansible/modules/network/f5/bigip_remote_role.py +++ b/lib/ansible/modules/network/f5/bigip_remote_role.py @@ -540,8 +540,9 @@ def main(): supports_check_mode=spec.supports_check_mode, ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_software_image.py b/lib/ansible/modules/network/f5/bigip_software_image.py index 72774b8f79..8ecd2a4228 100644 --- a/lib/ansible/modules/network/f5/bigip_software_image.py +++ b/lib/ansible/modules/network/f5/bigip_software_image.py @@ -467,8 +467,9 @@ def main(): supports_check_mode=spec.supports_check_mode ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_software_install.py b/lib/ansible/modules/network/f5/bigip_software_install.py index f8b91c9736..e28af62912 100644 --- a/lib/ansible/modules/network/f5/bigip_software_install.py +++ b/lib/ansible/modules/network/f5/bigip_software_install.py @@ -491,8 +491,9 @@ def main(): supports_check_mode=spec.supports_check_mode, ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_ssl_certificate.py b/lib/ansible/modules/network/f5/bigip_ssl_certificate.py index ebe7a890ec..6690b5d82e 100644 --- a/lib/ansible/modules/network/f5/bigip_ssl_certificate.py +++ b/lib/ansible/modules/network/f5/bigip_ssl_certificate.py @@ -564,6 +564,7 @@ def main(): argument_spec=spec.argument_spec, supports_check_mode=spec.supports_check_mode ) + client = F5RestClient(**module.params) try: diff --git a/lib/ansible/modules/network/f5/bigip_ssl_ocsp.py b/lib/ansible/modules/network/f5/bigip_ssl_ocsp.py index a6e0313e78..cd5ff7fd20 100644 --- a/lib/ansible/modules/network/f5/bigip_ssl_ocsp.py +++ b/lib/ansible/modules/network/f5/bigip_ssl_ocsp.py @@ -750,8 +750,9 @@ def main(): required_together=spec.required_together, ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_static_route.py b/lib/ansible/modules/network/f5/bigip_static_route.py index 592fa23a63..b5702cdeed 100644 --- a/lib/ansible/modules/network/f5/bigip_static_route.py +++ b/lib/ansible/modules/network/f5/bigip_static_route.py @@ -686,8 +686,9 @@ def main(): mutually_exclusive=spec.mutually_exclusive, ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_tunnel.py b/lib/ansible/modules/network/f5/bigip_tunnel.py index c4fd87f435..9961ee628b 100644 --- a/lib/ansible/modules/network/f5/bigip_tunnel.py +++ b/lib/ansible/modules/network/f5/bigip_tunnel.py @@ -599,8 +599,9 @@ def main(): supports_check_mode=spec.supports_check_mode, ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() cleanup_tokens(client) diff --git a/lib/ansible/modules/network/f5/bigip_wait.py b/lib/ansible/modules/network/f5/bigip_wait.py index 9ceafd5adf..548d7a8e53 100644 --- a/lib/ansible/modules/network/f5/bigip_wait.py +++ b/lib/ansible/modules/network/f5/bigip_wait.py @@ -206,6 +206,9 @@ class ModuleManager(object): self._wait_for_module_provisioning() break except Exception as ex: + if 'Failed to validate the SSL' in str(ex): + raise F5ModuleError(str(ex)) + # The types of exception's we're handling here are "REST API is not # ready" exceptions. # @@ -331,8 +334,9 @@ def main(): supports_check_mode=spec.supports_check_mode ) + client = F5RestClient(**module.params) + try: - client = F5RestClient(**module.params) mm = ModuleManager(module=module, client=client) results = mm.exec_module() exit_json(module, results, client) diff --git a/lib/ansible/utils/module_docs_fragments/f5.py b/lib/ansible/utils/module_docs_fragments/f5.py index 27da84473e..798bd9ced6 100644 --- a/lib/ansible/utils/module_docs_fragments/f5.py +++ b/lib/ansible/utils/module_docs_fragments/f5.py @@ -102,19 +102,15 @@ options: description: - Configures the transport connection to use when connecting to the remote device. - required: true choices: - rest - cli - default: cli + default: rest notes: - For more information on using Ansible to manage F5 Networks devices see U(https://www.ansible.com/integrations/networks/f5). - - Requires the f5-sdk Python package on the host. This is as easy as C(pip install f5-sdk). - Requires BIG-IP software version >= 12. - The F5 modules only manipulate the running configuration of the F5 product. To ensure that BIG-IP specific configuration persists to disk, be sure to include at least one task that uses the M(bigip_config) module to save the running configuration. Refer to the module's documentation for the correct usage of the module to save your running configuration. -requirements: - - f5-sdk >= 3.0.16 '''