Adds various features and fixes (#39271)

* a refactor of pool member and node modules to be inline with current f5 conventions
* Added priority_group_activation to pools
* various other small convention fixes and bug fixes
pull/39366/head
Tim Rupp 7 years ago committed by GitHub
parent 1c49cc4377
commit fb264281de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,7 @@ DOCUMENTATION = r'''
module: bigip_monitor_udp
short_description: Manages F5 BIG-IP LTM udp monitors
description: Manages F5 BIG-IP LTM udp monitors.
version_added: "2.5"
version_added: 2.5
options:
name:
description:
@ -150,30 +150,23 @@ import os
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
HAS_DEVEL_IMPORTS = False
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
@ -208,11 +201,6 @@ class Parameters(AnsibleF5Parameters):
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up'
]
def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value
def to_return(self):
result = {}
try:

@ -18,7 +18,7 @@ module: bigip_node
short_description: Manages F5 BIG-IP LTM nodes
description:
- Manages F5 BIG-IP LTM nodes.
version_added: "1.4"
version_added: 1.4
options:
state:
description:
@ -59,12 +59,12 @@ options:
quorum:
description:
- Monitor quorum value when C(monitor_type) is C(m_of_n).
version_added: "2.2"
version_added: 2.2
monitors:
description:
- Specifies the health monitors that the system currently uses to
monitor this node.
version_added: "2.2"
version_added: 2.2
address:
description:
- IP address of the node. This can be either IPv4 or IPv6. When creating a
@ -73,7 +73,7 @@ options:
aliases:
- ip
- host
version_added: "2.2"
version_added: 2.2
fqdn:
description:
- FQDN name of the node. This can be any name that is a valid RFC 1123 DNS
@ -86,7 +86,7 @@ options:
provided. This parameter cannot be updated after it is set.
aliases:
- hostname
version_added: "2.5"
version_added: 2.5
description:
description:
- Specifies descriptive text that identifies the node.
@ -97,7 +97,9 @@ options:
version_added: 2.5
notes:
- Requires the netaddr Python package on the host. This is as easy as
pip install netaddr
C(pip install netaddr).
requirements:
- netaddr
extends_documentation_fragment: f5
author:
- Tim Rupp (@caphrim007)
@ -216,30 +218,25 @@ import time
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
HAS_DEVEL_IMPORTS = False
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 fq_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 fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
@ -291,11 +288,6 @@ class Parameters(AnsibleF5Parameters):
except Exception:
return result
def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value
@property
def monitors_list(self):
if self._values['monitors'] is None:
@ -310,13 +302,12 @@ class Parameters(AnsibleF5Parameters):
def monitors(self):
if self._values['monitors'] is None:
return None
monitors = [self._fqdn_name(x) for x in self.monitors_list]
monitors = [fq_name(self.partition, x) for x in self.monitors_list]
if self.monitor_type == 'm_of_n':
monitors = ' '.join(monitors)
result = 'min %s of { %s }' % (self.quorum, monitors)
else:
result = ' and '.join(monitors).strip()
return result
@property

@ -18,7 +18,7 @@ module: bigip_partition
short_description: Manage BIG-IP partitions
description:
- Manage BIG-IP partitions.
version_added: "2.5"
version_added: 2.5
options:
name:
description:
@ -107,30 +107,23 @@ description:
from ansible.module_utils.basic import AnsibleModule
HAS_DEVEL_IMPORTS = False
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

@ -23,7 +23,7 @@ description:
the description, and things unrelated to the policy rules themselves.
It is also the first module that should be used when creating rules as
the C(bigip_policy_rule) module requires a policy parameter.
version_added: "2.5"
version_added: 2.5
options:
description:
description:
@ -168,30 +168,23 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
from distutils.version import LooseVersion
HAS_DEVEL_IMPORTS = False
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

@ -41,7 +41,7 @@ options:
- When C(type) is C(ignore), will remove all existing actions from this
rule.
required: true
choices: [ 'forward', 'enable', 'ignore' ]
choices: ['forward', 'enable', 'ignore']
pool:
description:
- Pool that you want to forward traffic to.
@ -77,7 +77,7 @@ options:
list will provide a match.
- When C(type) is C(all_traffic), will remove all existing conditions from
this rule.
required: true
required: True
choices: [ 'http_uri', 'all_traffic' ]
path_begins_with_any:
description:
@ -120,6 +120,7 @@ EXAMPLES = r'''
actions:
- type: forward
pool: pool-svrs
delegate_to: localhost
- name: Add multiple rules to the new policy
bigip_policy_rule:
@ -127,6 +128,7 @@ EXAMPLES = r'''
name: "{{ item.name }}"
conditions: "{{ item.conditions }}"
actions: "{{ item.actions }}"
delegate_to: localhost
loop:
- name: rule1
actions:
@ -151,6 +153,7 @@ EXAMPLES = r'''
- type: all_traffic
actions:
- type: ignore
delegate_to: localhost
'''
RETURN = r'''
@ -197,30 +200,25 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.six import iteritems
HAS_DEVEL_IMPORTS = False
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 fq_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 fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
@ -241,10 +239,9 @@ class Parameters(AnsibleF5Parameters):
'actions', 'conditions', 'description'
]
def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value
returnable = [
'description'
]
@property
def name(self):
@ -254,13 +251,6 @@ class Parameters(AnsibleF5Parameters):
def description(self):
return self._values.get('description', None)
@property
def strategy(self):
if self._values['strategy'] is None:
return None
result = self._fqdn_name(self._values['strategy'])
return result
@property
def policy(self):
if self._values['policy'] is None:
@ -407,7 +397,7 @@ class ModuleParameters(Parameters):
raise F5ModuleError(
"A 'pool' must be specified when the 'forward' type is used."
)
action['pool'] = self._fqdn_name(item['pool'])
action['pool'] = fq_name(self.partition, item['pool'])
def _handle_enable_action(self, action, item):
"""Handle the nuances of the enable type
@ -422,7 +412,7 @@ class ModuleParameters(Parameters):
"An 'asm_policy' must be specified when the 'enable' type is used."
)
action.update(dict(
policy=self._fqdn_name(item['asm_policy']),
policy=fq_name(self.partition, item['asm_policy']),
asm=True
))
@ -836,9 +826,9 @@ class ArgumentSpec(object):
'all_traffic'
],
required=True
)
),
path_begins_with_any=dict()
),
path_begins_with_any=dict()
),
name=dict(required=True),
policy=dict(required=True),

@ -23,7 +23,7 @@ options:
description:
description:
- Specifies descriptive text that identifies the pool.
version_added: "2.3"
version_added: 2.3
name:
description:
- Pool name
@ -34,7 +34,7 @@ options:
description:
- Load balancing method. When creating a new pool, if this value is not
specified, the default of C(round-robin) will be used.
version_added: "1.3"
version_added: 1.3
choices:
- dynamic-ratio-member
- dynamic-ratio-node
@ -54,7 +54,7 @@ options:
- ratio-session
- round-robin
- weighted-least-connections-member
- weighted-least-connections-nod
- weighted-least-connections-node
monitor_type:
description:
- Monitor rule type when C(monitors) is specified.
@ -69,32 +69,32 @@ options:
or already existing on the device.
- Both C(single) and C(and_list) are functionally identical since BIG-IP
considers all monitors as "a list".
version_added: "1.3"
version_added: 1.3
choices: ['and_list', 'm_of_n', 'single']
quorum:
description:
- Monitor quorum value when C(monitor_type) is C(m_of_n).
- Quorum must be a value of 1 or greater when C(monitor_type) is C(m_of_n).
version_added: "1.3"
version_added: 1.3
monitors:
description:
- Monitor template name list. If the partition is not provided as part of
the monitor name, then the C(partition) option will be used instead.
version_added: "1.3"
version_added: 1.3
slow_ramp_time:
description:
- Sets the ramp-up time (in seconds) to gradually ramp up the load on
newly added or freshly detected up pool members.
version_added: "1.3"
version_added: 1.3
reselect_tries:
description:
- Sets the number of times the system tries to contact a pool member
after a passive failure.
version_added: "2.2"
version_added: 2.2
service_down_action:
description:
- Sets the action to take when node goes down in pool.
version_added: "1.3"
version_added: 1.3
choices:
- none
- reset
@ -124,6 +124,25 @@ options:
that are numbers.
- Data will be persisted, not ephemeral.
version_added: 2.5
priority_group_activation:
description:
- Specifies whether the system load balances traffic according to the priority
number assigned to the pool member.
- When creating a new pool, if this parameter is not specified, the default of
C(0) will be used.
- To disable this setting, provide the value C(0).
- Once you enable this setting, you can specify pool member priority when you
create a new pool or on a pool member's properties screen.
- The system treats same-priority pool members as a group.
- To enable priority group activation, provide a number from C(0) to C(65535)
that represents the minimum number of members that must be available in one
priority group before the system directs traffic to members in a lower
priority group.
- When a sufficient number of members become available in the higher priority
group, the system again directs traffic to the higher priority group.
aliases:
- minimum_active_members
version_added: 2.6
notes:
- Requires BIG-IP software version >= 12.
- To add members do a pool, use the C(bigip_pool_member) module. Previously, the
@ -144,7 +163,7 @@ EXAMPLES = r'''
state: present
name: my-pool
partition: Common
lb_method: least-connection-member
lb_method: least-connections-member
slow_ramp_time: 120
delegate_to: localhost
@ -307,6 +326,11 @@ metadata:
returned: changed
type: dict
sample: {'key1': 'foo', 'key2': 'bar'}
priority_group_activation:
description: The new minimum number of members to activate the priorty group.
returned: changed
type: int
sample: 10
'''
import re
@ -315,30 +339,25 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.six import iteritems
HAS_DEVEL_IMPORTS = False
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 fq_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 fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
@ -358,24 +377,26 @@ class Parameters(AnsibleF5Parameters):
'slowRampTime': 'slow_ramp_time',
'reselectTries': 'reselect_tries',
'serviceDownAction': 'service_down_action',
'monitor': 'monitors'
'monitor': 'monitors',
'minActiveMembers': 'priority_group_activation'
}
api_attributes = [
'description', 'name', 'loadBalancingMode', 'monitor', 'slowRampTime',
'reselectTries', 'serviceDownAction', 'metadata'
'reselectTries', 'serviceDownAction', 'metadata', 'minActiveMembers'
]
returnables = [
'monitor_type', 'quorum', 'monitors', 'service_down_action',
'description', 'lb_method', 'slow_ramp_time',
'reselect_tries', 'monitor', 'name', 'partition', 'metadata'
'reselect_tries', 'monitor', 'name', 'partition', 'metadata',
'priority_group_activation'
]
updatables = [
'monitor_type', 'quorum', 'monitors', 'service_down_action',
'description', 'lb_method', 'slow_ramp_time', 'reselect_tries',
'metadata'
'metadata', 'priority_group_activation'
]
@property
@ -389,16 +410,21 @@ class Parameters(AnsibleF5Parameters):
raise F5ModuleError('Provided lb_method is unknown')
return lb_method
def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value
def _verify_quorum_type(self, quorum):
try:
if quorum is None:
return None
return int(quorum)
except ValueError:
raise F5ModuleError(
"The specified 'quorum' must be an integer."
)
@property
def monitors(self):
if self._values['monitors'] is None:
return None
monitors = [self._fqdn_name(x) for x in self.monitors_list]
monitors = [fq_name(self.partition, x) for x in self.monitors_list]
if self.monitor_type == 'm_of_n':
monitors = ' '.join(monitors)
result = 'min %s of { %s }' % (self.quorum, monitors)
@ -406,15 +432,11 @@ class Parameters(AnsibleF5Parameters):
result = ' and '.join(monitors).strip()
return result
def _verify_quorum_type(self, quorum):
try:
if quorum is None:
return None
return int(quorum)
except ValueError:
raise F5ModuleError(
"The specified 'quorum' must be an integer."
)
@property
def priority_group_activation(self):
if self._values['priority_group_activation'] is None:
return None
return int(self._values['priority_group_activation'])
class ApiParameters(Parameters):
@ -447,7 +469,7 @@ class ApiParameters(Parameters):
if self._values['monitors'] is None:
return []
try:
result = re.findall(r'/\w+/[^\s}]+', self._values['monitors'])
result = re.findall(r'/[\w-]+/[^\s}]+', self._values['monitors'])
return result
except Exception:
return self._values['monitors']
@ -534,7 +556,7 @@ class UsableChanges(Changes):
class ReportableChanges(Changes):
@property
def monitors(self):
result = sorted(re.findall(r'/\w+/[^\s}]+', self._values['monitors']))
result = sorted(re.findall(r'/[\w-]+/[^\s}]+', self._values['monitors']))
return result
@property
@ -794,6 +816,8 @@ class ModuleManager(object):
raise F5ModuleError(
"When using a 'monitor_type' of 'single', only one monitor may be provided"
)
if self.want.priority_group_activation is None:
self.want.update({'priority_group_activation': 0})
self._set_changed_options()
if self.module.check_mode:
@ -903,6 +927,10 @@ class ArgumentSpec(object):
partition=dict(
default='Common',
fallback=(env_fallback, ['F5_PARTITION'])
),
priority_group_activation=dict(
type='int',
aliases=['minimum_active_members']
)
)
self.argument_spec = {}

File diff suppressed because it is too large Load Diff

@ -16,8 +16,9 @@ DOCUMENTATION = r'''
---
module: bigip_profile_client_ssl
short_description: Manages client SSL profiles on a BIG-IP
description: Manages client SSL profiles on a BIG-IP.
version_added: "2.5"
description:
- Manages client SSL profiles on a BIG-IP.
version_added: 2.5
options:
name:
description:
@ -41,7 +42,8 @@ options:
type of each certificate/key type. This means that you can only have one
RSA, one DSA, and one ECDSA per profile. If you attempt to assign two
RSA, DSA, or ECDSA certificate/key combo, the device will reject this.
- This list is a complex list that specifies a number of keys. There are several supported keys.
- This list is a complex list that specifies a number of keys. There are
several supported keys.
suboptions:
cert:
description:
@ -131,30 +133,25 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.six import iteritems
HAS_DEVEL_IMPORTS = False
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 fq_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 fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
@ -181,11 +178,6 @@ class Parameters(AnsibleF5Parameters):
class ModuleParameters(Parameters):
def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value
def _key_filename(self, name):
if name.endswith('.key'):
return name
@ -202,14 +194,14 @@ class ModuleParameters(Parameters):
if 'chain' not in item or item['chain'] == 'none':
result = 'none'
else:
result = self._cert_filename(self._fqdn_name(item['chain']))
result = self._cert_filename(fq_name(self.partition, item['chain']))
return result
@property
def parent(self):
if self._values['parent'] is None:
return None
result = self._fqdn_name(self._values['parent'])
result = fq_name(self.partition, self._values['parent'])
return result
@property
@ -233,8 +225,8 @@ class ModuleParameters(Parameters):
filename, ex = os.path.splitext(name)
tmp = {
'name': filename,
'cert': self._fqdn_name(cert),
'key': self._fqdn_name(key),
'cert': fq_name(self.partition, cert),
'key': fq_name(self.partition, key),
'chain': chain
}
if 'passphrase' in item:

@ -1079,7 +1079,6 @@ lib/ansible/modules/network/f5/bigip_iapp_service.py E324
lib/ansible/modules/network/f5/bigip_iapp_service.py E325
lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py E326
lib/ansible/modules/network/f5/bigip_policy.py E324
lib/ansible/modules/network/f5/bigip_pool.py E326
lib/ansible/modules/network/f5/bigip_profile_client_ssl.py E324
lib/ansible/modules/network/f5/bigip_selfip.py E324
lib/ansible/modules/network/f5/bigip_sys_global.py E326

@ -0,0 +1,25 @@
{
"kind": "tm:ltm:node:nodestate",
"name": "foo.bar.com",
"partition": "Common",
"fullPath": "/Common/foo.bar.com",
"generation": 157,
"selfLink": "https://localhost/mgmt/tm/ltm/node/~Common~foo.bar.com?ver=12.0.0",
"address": "any6",
"connectionLimit": 0,
"dynamicRatio": 1,
"ephemeral": "false",
"fqdn": {
"addressFamily": "ipv4",
"autopopulate": "enabled",
"downInterval": 5,
"interval": "3600",
"tmName": "foo.bar.com"
},
"logging": "disabled",
"monitor": "default",
"rateLimit": "disabled",
"ratio": 1,
"session": "user-enabled",
"state": "fqdn-up-no-addr"
}

@ -0,0 +1,24 @@
{
"kind": "tm:ltm:node:nodestate",
"name": "7.3.67.8",
"partition": "Common",
"fullPath": "/Common/7.3.67.8",
"generation": 162,
"selfLink": "https://localhost/mgmt/tm/ltm/node/~Common~7.3.67.8?ver=12.0.0",
"address": "7.3.67.8",
"connectionLimit": 0,
"dynamicRatio": 1,
"ephemeral": "false",
"fqdn": {
"addressFamily": "ipv4",
"autopopulate": "disabled",
"downInterval": 5,
"interval": "3600"
},
"logging": "disabled",
"monitor": "default",
"rateLimit": "disabled",
"ratio": 1,
"session": "user-enabled",
"state": "unchecked"
}

@ -21,9 +21,9 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_monitor_udp import Parameters
from library.bigip_monitor_udp import ModuleManager
from library.bigip_monitor_udp import ArgumentSpec
from library.modules.bigip_monitor_udp import Parameters
from library.modules.bigip_monitor_udp import ModuleManager
from library.modules.bigip_monitor_udp import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -20,9 +20,9 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_node import Parameters
from library.bigip_node import ModuleManager
from library.bigip_node import ArgumentSpec
from library.modules.bigip_node import Parameters
from library.modules.bigip_node import ModuleManager
from library.modules.bigip_node import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -20,9 +20,9 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_partition import Parameters
from library.bigip_partition import ModuleManager
from library.bigip_partition import ArgumentSpec
from library.modules.bigip_partition import Parameters
from library.modules.bigip_partition import ModuleManager
from library.modules.bigip_partition import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -20,11 +20,11 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_policy import Parameters
from library.bigip_policy import ModuleManager
from library.bigip_policy import SimpleManager
from library.bigip_policy import ComplexManager
from library.bigip_policy import ArgumentSpec
from library.modules.bigip_policy import Parameters
from library.modules.bigip_policy import ModuleManager
from library.modules.bigip_policy import SimpleManager
from library.modules.bigip_policy import ComplexManager
from library.modules.bigip_policy import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -20,11 +20,11 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_policy_rule import Parameters
from library.bigip_policy_rule import ModuleParameters
from library.bigip_policy_rule import ApiParameters
from library.bigip_policy_rule import ModuleManager
from library.bigip_policy_rule import ArgumentSpec
from library.modules.bigip_policy_rule import Parameters
from library.modules.bigip_policy_rule import ModuleParameters
from library.modules.bigip_policy_rule import ApiParameters
from library.modules.bigip_policy_rule import ModuleManager
from library.modules.bigip_policy_rule import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -21,10 +21,10 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_pool import ApiParameters
from library.bigip_pool import ModuleParameters
from library.bigip_pool import ModuleManager
from library.bigip_pool import ArgumentSpec
from library.modules.bigip_pool import ApiParameters
from library.modules.bigip_pool import ModuleParameters
from library.modules.bigip_pool import ModuleManager
from library.modules.bigip_pool import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

@ -0,0 +1,338 @@
# -*- coding: utf-8 -*-
#
# 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
import os
import json
import pytest
import sys
from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7")
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.modules.bigip_pool_member import ModuleParameters
from library.modules.bigip_pool_member import ApiParameters
from library.modules.bigip_pool_member import NodeApiParameters
from library.modules.bigip_pool_member import ModuleManager
from library.modules.bigip_pool_member import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args
except ImportError:
try:
from ansible.modules.network.f5.bigip_pool_member import ModuleParameters
from ansible.modules.network.f5.bigip_pool_member import ApiParameters
from ansible.modules.network.f5.bigip_pool_member import NodeApiParameters
from ansible.modules.network.f5.bigip_pool_member import ModuleManager
from ansible.modules.network.f5.bigip_pool_member import ArgumentSpec
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
if path in fixture_data:
return fixture_data[path]
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
fixture_data[path] = data
return data
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
pool='my-pool',
address='1.2.3.4',
fqdn='fqdn.foo.bar',
name='my-name',
port=2345,
connection_limit=100,
description='this is a description',
rate_limit=70,
ratio=20,
preserve_node=False,
priority_group=10,
state='present',
partition='Common',
fqdn_auto_populate=False,
reuse_nodes=False,
# Deprecated params
# TODO(Remove in 2.7)
session_state='disabled',
monitor_state='disabled',
)
p = ModuleParameters(params=args)
assert p.name == 'my-name'
def test_api_parameters(self):
args = load_fixture('load_net_node_with_fqdn.json')
p = ApiParameters(params=args)
assert p.state == 'present'
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
def test_create_reuse_node_with_name(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='my-name',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
password='password',
server='localhost',
user='admin'
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_fqdn.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
mm.read_current_node_from_device = Mock(return_value=current_node)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is True
assert results['fqdn'] == 'foo.bar.com'
assert results['state'] == 'present'
def test_create_reuse_node_with_ipv4_address(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='7.3.67.8',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
password='password',
server='localhost',
user='admin'
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_ipv4_address.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
mm.read_current_node_from_device = Mock(return_value=current_node)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is False
assert results['address'] == '7.3.67.8'
assert results['state'] == 'present'
def test_create_reuse_node_with_fqdn_auto_populate(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='my-name',
port=2345,
state='present',
partition='Common',
reuse_nodes=True,
fqdn_auto_populate=False,
password='password',
server='localhost',
user='admin'
))
current_node = NodeApiParameters(params=load_fixture('load_net_node_with_fqdn.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
mm.read_current_node_from_device = Mock(return_value=current_node)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is True
assert results['fqdn'] == 'foo.bar.com'
assert results['state'] == 'present'
class TestLegacyManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
def test_create_name_is_hostname_with_session_and_monitor_enabled(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='my-name',
port=2345,
state='present',
session_state='enabled',
monitor_state='enabled',
partition='Common',
password='password',
server='localhost',
user='admin'
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is False
assert results['fqdn'] == 'my-name'
assert results['state'] == 'present'
def test_create_name_is_address_with_session_and_monitor_enabled(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='10.10.10.10',
port=2345,
state='present',
session_state='enabled',
monitor_state='enabled',
partition='Common',
password='password',
server='localhost',
user='admin'
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is False
assert results['address'] == '10.10.10.10'
assert results['state'] == 'present'
def test_create_name_is_address_with_session_disabled_and_monitor_enabled(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='10.10.10.10',
port=2345,
state='present',
monitor_state='enabled',
session_state='disabled',
partition='Common',
password='password',
server='localhost',
user='admin'
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is False
assert results['address'] == '10.10.10.10'
assert results['state'] == 'disabled'
def test_create_name_is_address_with_session_and_monitor_disabled(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
pool='my-pool',
name='10.10.10.10',
port=2345,
state='present',
monitor_state='disabled',
session_state='disabled',
partition='Common',
password='password',
server='localhost',
user='admin'
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.exists = Mock(return_value=False)
mm.create_on_device = Mock(return_value=True)
results = mm.exec_module()
assert results['changed'] is True
assert results['fqdn_auto_populate'] is False
assert results['address'] == '10.10.10.10'
assert results['state'] == 'forced_offline'

@ -21,10 +21,10 @@ from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
from library.bigip_profile_client_ssl import ModuleParameters
from library.bigip_profile_client_ssl import ApiParameters
from library.bigip_profile_client_ssl import ModuleManager
from library.bigip_profile_client_ssl import ArgumentSpec
from library.modules.bigip_profile_client_ssl import ModuleParameters
from library.modules.bigip_profile_client_ssl import ApiParameters
from library.modules.bigip_profile_client_ssl import ModuleManager
from library.modules.bigip_profile_client_ssl import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args

Loading…
Cancel
Save