1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Minor bigip fixes (#34971)

Updating docs in modules. fixing imports
This commit is contained in:
Tim Rupp 2018-01-16 21:02:33 -08:00 committed by GitHub
parent 290b1651ae
commit e9b52aca64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 86 deletions

View file

@ -97,9 +97,14 @@ except ImportError:
pass # Handle via f5_utils.bigsuds_found pass # Handle via f5_utils.bigsuds_found
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.f5_utils import bigip_api, bigsuds_found, f5_argument_spec from ansible.module_utils.f5_utils import bigip_api, bigsuds_found
from ansible.module_utils.six.moves import map, zip from ansible.module_utils.six.moves import map, zip
try:
from library.module_utils.network.f5.common import f5_argument_spec
except ImportError:
from ansible.module_utils.network.f5.common import f5_argument_spec
class F5(object): class F5(object):
"""F5 iControl class. """F5 iControl class.
@ -1640,8 +1645,7 @@ def generate_provision_dict(f5):
def main(): def main():
argument_spec = f5_argument_spec() argument_spec = f5_argument_spec
meta_args = dict( meta_args = dict(
session=dict(type='bool', default=False), session=dict(type='bool', default=False),
include=dict(type='list', required=True), include=dict(type='list', required=True),

View file

@ -5,16 +5,20 @@
# Copyright (c) 2013 Matt Hite <mhite@hotmail.com> # Copyright (c) 2013 Matt Hite <mhite@hotmail.com>
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # 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
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = r'''
--- ---
module: bigip_pool_member module: bigip_pool_member
short_description: Manages F5 BIG-IP LTM pool members short_description: Manages F5 BIG-IP LTM pool members
description: description:
- Manages F5 BIG-IP LTM pool members via iControl SOAP API - Manages F5 BIG-IP LTM pool members via iControl SOAP API.
version_added: 1.4 version_added: 1.4
author: author:
- Matt Hite (@mhite) - Matt Hite (@mhite)
@ -29,134 +33,114 @@ requirements:
options: options:
state: state:
description: description:
- Pool member state - Pool member state.
required: true required: True
default: present default: present
choices: choices:
- present - present
- absent - absent
session_state: session_state:
description: description:
- Set new session availability status for pool member - Set new session availability status for pool member.
version_added: 2.0 version_added: 2.0
required: false
default: null
choices: choices:
- enabled - enabled
- disabled - disabled
monitor_state: monitor_state:
description: description:
- Set monitor availability status for pool member - Set monitor availability status for pool member.
version_added: 2.0 version_added: 2.0
required: false
default: null
choices: choices:
- enabled - enabled
- disabled - disabled
pool: pool:
description: description:
- Pool name. This pool must exist. - Pool name. This pool must exist.
required: true required: True
partition: partition:
description: description:
- Partition - Partition
required: false default: Common
default: 'Common'
host: host:
description: description:
- Pool member IP - Pool member IP.
required: true required: True
aliases: aliases:
- address - address
- name - name
port: port:
description: description:
- Pool member port - Pool member port.
required: true required: True
connection_limit: connection_limit:
description: description:
- Pool member connection limit. Setting this to 0 disables the limit. - Pool member connection limit. Setting this to 0 disables the limit.
required: false
default: null
description: description:
description: description:
- Pool member description - Pool member description.
required: false
default: null
rate_limit: rate_limit:
description: description:
- Pool member rate limit (connections-per-second). Setting this to 0 - Pool member rate limit (connections-per-second). Setting this to 0
disables the limit. disables the limit.
required: false
default: null
ratio: ratio:
description: description:
- Pool member ratio weight. Valid values range from 1 through 100. - Pool member ratio weight. Valid values range from 1 through 100.
New pool members -- unless overridden with this value -- default New pool members -- unless overridden with this value -- default
to 1. to 1.
required: false
default: null
preserve_node: preserve_node:
description: description:
- When state is absent and the pool member is no longer referenced - When state is absent and the pool member is no longer referenced
in other pools, the default behavior removes the unused node in other pools, the default behavior removes the unused node
o bject. Setting this to 'yes' disables this behavior. o bject. Setting this to 'yes' disables this behavior.
required: false default: no
default: 'no'
choices: choices:
- yes - yes
- no - no
version_added: 2.1 version_added: 2.1
priority_group:
description:
- Sets priority group for a pool member.
required: false
default: null
version_added: 2.4
extends_documentation_fragment: f5 extends_documentation_fragment: f5
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: Add pool member - name: Add pool member
bigip_pool_member: bigip_pool_member:
server: "lb.mydomain.com" server: lb.mydomain.com
user: "admin" user: admin
password: "secret" password: secret
state: "present" state: present
pool: "my-pool" pool: my-pool
partition: "Common" partition: Common
host: "{{ ansible_default_ipv4['address'] }}" host: "{{ ansible_default_ipv4['address'] }}"
port: 80 port: 80
description: "web server" description: web server
connection_limit: 100 connection_limit: 100
rate_limit: 50 rate_limit: 50
ratio: 2 ratio: 2
delegate_to: localhost delegate_to: localhost
- name: Modify pool member ratio and description - name: Modify pool member ratio and description
bigip_pool_member: bigip_pool_member:
server: "lb.mydomain.com" server: lb.mydomain.com
user: "admin" user: admin
password: "secret" password: secret
state: "present" state: present
pool: "my-pool" pool: my-pool
partition: "Common" partition: Common
host: "{{ ansible_default_ipv4['address'] }}" host: "{{ ansible_default_ipv4['address'] }}"
port: 80 port: 80
ratio: 1 ratio: 1
description: "nginx server" description: nginx server
delegate_to: localhost delegate_to: localhost
- name: Remove pool member from pool - name: Remove pool member from pool
bigip_pool_member: bigip_pool_member:
server: "lb.mydomain.com" server: lb.mydomain.com
user: "admin" user: admin
password: "secret" password: secret
state: "absent" state: absent
pool: "my-pool" pool: my-pool
partition: "Common" partition: Common
host: "{{ ansible_default_ipv4['address'] }}" host: "{{ ansible_default_ipv4['address'] }}"
port: 80 port: 80
delegate_to: localhost delegate_to: localhost
@ -175,19 +159,38 @@ EXAMPLES = '''
- name: Force pool member offline - name: Force pool member offline
bigip_pool_member: bigip_pool_member:
server: "lb.mydomain.com" server: lb.mydomain.com
user: "admin" user: admin
password: "secret" password: secret
state: "present" state: present
session_state: "disabled" session_state: disabled
monitor_state: "disabled" monitor_state: disabled
pool: "my-pool" pool: my-pool
partition: "Common" partition: Common
host: "{{ ansible_default_ipv4['address'] }}" host: "{{ ansible_default_ipv4['address'] }}"
port: 80 port: 80
delegate_to: localhost delegate_to: localhost
''' '''
try:
import bigsuds
HAS_BIGSUDS = True
except ImportError:
pass # Handled by f5_utils.bigsuds_found
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.f5_utils import bigip_api, bigsuds_found
HAS_DEVEL_IMPORTS = False
try:
from library.module_utils.network.f5.common import f5_argument_spec
from library.module_utils.network.f5.common import fqdn_name
HAS_DEVEL_IMPORTS = True
except ImportError:
from ansible.module_utils.network.f5.common import fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec
def pool_exists(api, pool): def pool_exists(api, pool):
# hack to determine if pool exists # hack to determine if pool exists
@ -382,7 +385,8 @@ def get_member_monitor_status(api, pool, address, port):
def main(): def main():
argument_spec = f5_argument_spec() result = {}
argument_spec = f5_argument_spec
meta_args = dict( meta_args = dict(
session_state=dict(type='str', choices=['enabled', 'disabled']), session_state=dict(type='str', choices=['enabled', 'disabled']),
@ -404,12 +408,15 @@ def main():
supports_check_mode=True supports_check_mode=True
) )
if not bigsuds_found:
module.fail_json(msg="the python bigsuds module is required")
if module.params['validate_certs']: if module.params['validate_certs']:
import ssl import ssl
if not hasattr(ssl, 'SSLContext'): if not hasattr(ssl, 'SSLContext'):
module.fail_json( module.fail_json(
msg='bigsuds does not support verifying certificates with python < 2.7.9. Either update python or set validate_certs=False on the task' msg='bigsuds does not support verifying certificates with python < 2.7.9. '
) 'Either update python or set validate_certs=False on the task')
server = module.params['server'] server = module.params['server']
server_port = module.params['server_port'] server_port = module.params['server_port']
@ -421,14 +428,14 @@ def main():
session_state = module.params['session_state'] session_state = module.params['session_state']
monitor_state = module.params['monitor_state'] monitor_state = module.params['monitor_state']
pool = fq_name(partition, module.params['pool']) pool = fqdn_name(partition, module.params['pool'])
connection_limit = module.params['connection_limit'] connection_limit = module.params['connection_limit']
description = module.params['description'] description = module.params['description']
rate_limit = module.params['rate_limit'] rate_limit = module.params['rate_limit']
ratio = module.params['ratio'] ratio = module.params['ratio']
priority_group = module.params['priority_group'] priority_group = module.params['priority_group']
host = module.params['host'] host = module.params['host']
address = fq_name(partition, host) address = fqdn_name(partition, host)
port = module.params['port'] port = module.params['port']
preserve_node = module.params['preserve_node'] preserve_node = module.params['preserve_node']
@ -523,8 +530,6 @@ def main():
module.exit_json(**result) module.exit_json(**result)
from ansible.module_utils.basic import *
from ansible.module_utils.f5_utils import *
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -60,8 +60,8 @@ options:
IP, this value is required. IP, this value is required.
route_domain: route_domain:
description: description:
- The route domain id of the system. When creating a new Self IP, if - The route domain id of the system. When creating a new Self IP, if
this value is not specified, a default value of C(0) will be used. this value is not specified, a default value of C(0) will be used.
version_added: 2.3 version_added: 2.3
partition: partition:
description: description: