diff --git a/lib/ansible/modules/network/f5/bigip_provision.py b/lib/ansible/modules/network/f5/bigip_provision.py index de3a1463fc..6b53e20455 100644 --- a/lib/ansible/modules/network/f5/bigip_provision.py +++ b/lib/ansible/modules/network/f5/bigip_provision.py @@ -21,7 +21,7 @@ description: standard levels of Dedicated, Nominal, and Minimum. version_added: "2.4" options: - module: + name: description: - The module to provision in BIG-IP. required: true @@ -40,6 +40,8 @@ options: - sam - swg - vcmp + aliases: + - module level: description: - Sets the provisioning level for the requested modules. Changing the @@ -109,9 +111,9 @@ from ansible.module_utils.f5_utils import AnsibleF5Client from ansible.module_utils.f5_utils import AnsibleF5Parameters from ansible.module_utils.f5_utils import HAS_F5SDK from ansible.module_utils.f5_utils import F5ModuleError -from f5.sdk_exception import LazyAttributesRequired try: + from f5.sdk_exception import LazyAttributesRequired from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError except ImportError: HAS_F5SDK = False @@ -207,11 +209,16 @@ class ModuleManager(object): return False if self.client.check_mode: return True + self.update_on_device() self._wait_for_module_provisioning() + if self.want.module == 'vcmp': self._wait_for_reboot() self._wait_for_module_provisioning() + + if self.want.module == 'asm': + self._wait_for_asm_ready() return True def should_update(self): @@ -294,6 +301,26 @@ class ModuleManager(object): pass return False + def _wait_for_asm_ready(self): + """Waits specifically for ASM + + On older versions, ASM can take longer to actually start up than + all the previous checks take. This check here is specifically waiting for + the Policies API to stop raising errors + :return: + """ + nops = 0 + while nops < 3: + try: + policies = self.client.api.tm.asm.policies_s.get_collection() + if len(policies) >= 0: + nops += 1 + else: + nops = 0 + except Exception: + pass + time.sleep(5) + def _get_last_reboot(self): output = self.client.api.tm.util.bash.exec_cmd( 'run', @@ -339,7 +366,8 @@ class ArgumentSpec(object): 'afm', 'am', 'sam', 'asm', 'avr', 'fps', 'gtm', 'lc', 'ltm', 'pem', 'swg', 'ilx', 'apm', 'vcmp' - ] + ], + aliases=['name'] ), level=dict( default='nominal', diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 9610985e03..94a159a465 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -14,7 +14,6 @@ lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py lib/ansible/modules/cloud/webfaction/webfaction_site.py lib/ansible/modules/clustering/consul_acl.py lib/ansible/modules/network/cloudengine/ce_file_copy.py -lib/ansible/modules/network/f5/bigip_provision.py lib/ansible/modules/network/f5/bigip_qkview.py lib/ansible/modules/network/f5/bigip_snmp.py lib/ansible/modules/network/ios/ios_static_route.py diff --git a/test/units/modules/network/f5/test_bigip_provision.py b/test/units/modules/network/f5/test_bigip_provision.py index 1415b557eb..35dba41099 100644 --- a/test/units/modules/network/f5/test_bigip_provision.py +++ b/test/units/modules/network/f5/test_bigip_provision.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright 2017 F5 Networks Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright (c) 2017 F5 Networks Inc. +# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type