Various bigip gtm server and vs enhancements (#40033)

* Refactor bigip_gtm_virtual_server
* Add translation_address to bigip_gtm_virtual_server
* Add translation_port to bigip_gtm_virtual_server
* Add availability_requirements to bigip_gtm_virtual_server
* Add monitors to bigip_gtm_virtual_server
* Add virtual_server_dependencies to bigip_gtm_virtual_server
* Add link to bigip_gtm_virtual_server
* Add limits to bigip_gtm_virtual_server
* Add partition to bigip_gtm_virtual_server
* Fix bigip_gtm_server to correctly create other server types
This commit is contained in:
Tim Rupp 2018-05-11 13:38:04 -07:00 committed by GitHub
parent 1aa248f4e2
commit 61e7c77dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1219 additions and 187 deletions

View file

@ -19,7 +19,7 @@ short_description: Manages F5 BIG-IP GTM servers
description:
- Manage BIG-IP server configuration. This module is able to manipulate the server
definitions in a BIG-IP.
version_added: "2.5"
version_added: 2.5
options:
name:
description:
@ -184,35 +184,27 @@ datacenter:
sample: datacenter01
'''
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
HAS_DEVEL_IMPORTS = False
from distutils.version import LooseVersion
try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens
from library.module_utils.network.f5.common import fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens
from ansible.module_utils.network.f5.common import fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
@ -420,12 +412,16 @@ class Difference(object):
devices = self.have.devices
else:
devices = self.want.devices
if self.have.devices is None:
have_devices = []
else:
have_devices = self.have.devices
if len(devices) == 0:
raise F5ModuleError(
"A GTM server must have at least one device associated with it."
)
want = [OrderedDict(sorted(d.items())) for d in devices]
have = [OrderedDict(sorted(d.items())) for d in self.have.devices]
have = [OrderedDict(sorted(d.items())) for d in have_devices]
if want != have:
return True
return False
@ -645,7 +641,9 @@ class BaseManager(object):
self.want.update({'disabled': True})
elif self.want.state in ['present', 'enabled']:
self.want.update({'enabled': True})
self._set_changed_options()
self.adjust_server_type_by_version()
self.should_update()
if self.want.devices is None:
raise F5ModuleError(
@ -662,7 +660,7 @@ class BaseManager(object):
raise F5ModuleError("Failed to create the server")
def create_on_device(self):
params = self.want.api_params()
params = self.changes.api_params()
self.client.api.tm.gtm.servers.server.create(
name=self.want.name,
partition=self.want.partition,
@ -740,17 +738,18 @@ class V1Manager(BaseManager):
self.want.update({'server_type': 'single-bigip'})
else:
self.want.update({'server_type': 'redundant-bigip'})
else:
if len(self.want.devices) == 1:
self.want.update({'server_type': 'single-bigip'})
else:
self.want.update({'server_type': 'redundant-bigip'})
if self.want.link_discovery is None:
self.want.update({'link_discovery': 'disabled'})
if self.want.virtual_server_discovery is None:
self.want.update({'virtual_server_discovery': 'disabled'})
self._check_link_discovery_requirements()
def adjust_server_type_by_version(self):
if len(self.want.devices) == 1 and self.want.server_type == 'bigip':
self.want.update({'server_type': 'single-bigip'})
if len(self.want.devices) > 1 and self.want.server_type == 'bigip':
self.want.update({'server_type': 'redundant-bigip'})
class V2Manager(BaseManager):
def _assign_creation_defaults(self):
@ -762,6 +761,9 @@ class V2Manager(BaseManager):
self.want.update({'virtual_server_discovery': 'disabled'})
self._check_link_discovery_requirements()
def adjust_server_type_by_version(self):
pass
class ArgumentSpec(object):
def __init__(self):

File diff suppressed because it is too large Load diff