|
|
@ -1,8 +1,8 @@
|
|
|
|
#!/usr/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
# Copyright (c) 2017 F5 Networks Inc.
|
|
|
|
# Copyright: (c) 2017, F5 Networks Inc.
|
|
|
|
# Copyright (c) 2015 Etienne Carriere <etienne.carriere@gmail.com>
|
|
|
|
# Copyright: (c) 2015, Etienne Carriere <etienne.carriere@gmail.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)
|
|
|
|
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
@ -12,43 +12,36 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: bigip_virtual_server
|
|
|
|
module: bigip_virtual_server
|
|
|
|
short_description: "Manages F5 BIG-IP LTM virtual servers"
|
|
|
|
short_description: Manages F5 BIG-IP LTM virtual servers
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- "Manages F5 BIG-IP LTM virtual servers via iControl SOAP API"
|
|
|
|
- Manages F5 BIG-IP LTM virtual servers via iControl SOAP API.
|
|
|
|
version_added: "2.1"
|
|
|
|
version_added: "2.1"
|
|
|
|
author:
|
|
|
|
author:
|
|
|
|
- Etienne Carriere (@Etienne-Carriere)
|
|
|
|
- Etienne Carriere (@Etienne-Carriere)
|
|
|
|
- Tim Rupp (@caphrim007)
|
|
|
|
- Tim Rupp (@caphrim007)
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- "Requires BIG-IP software version >= 11"
|
|
|
|
- Requires BIG-IP software version >= 11.
|
|
|
|
- "F5 developed module 'bigsuds' required (see http://devcentral.f5.com)"
|
|
|
|
- F5 developed module 'bigsuds' required, see U(http://devcentral.f5.com).
|
|
|
|
- "Best run as a local_action in your playbook"
|
|
|
|
- Best run as a local_action in your playbook.
|
|
|
|
requirements:
|
|
|
|
requirements:
|
|
|
|
- bigsuds
|
|
|
|
- bigsuds
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Virtual Server state
|
|
|
|
- Virtual Server state.
|
|
|
|
- Absent, delete the VS if present
|
|
|
|
- Absent, delete the VS if present.
|
|
|
|
- C(present) (and its synonym enabled), create if needed the VS and set
|
|
|
|
- C(present) (and its synonym enabled), create if needed the VS and set
|
|
|
|
state to enabled
|
|
|
|
state to enabled.
|
|
|
|
- C(disabled), create if needed the VS and set state to disabled
|
|
|
|
- C(disabled), create if needed the VS and set state to disabled.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: present
|
|
|
|
default: present
|
|
|
|
choices:
|
|
|
|
choices: [ absent, disabled, enabled, present ]
|
|
|
|
- present
|
|
|
|
|
|
|
|
- absent
|
|
|
|
|
|
|
|
- enabled
|
|
|
|
|
|
|
|
- disabled
|
|
|
|
|
|
|
|
aliases: []
|
|
|
|
|
|
|
|
partition:
|
|
|
|
partition:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Partition
|
|
|
|
- Partition.
|
|
|
|
required: false
|
|
|
|
default: Common
|
|
|
|
default: 'Common'
|
|
|
|
|
|
|
|
name:
|
|
|
|
name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Virtual server name
|
|
|
|
- Virtual server name.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
aliases:
|
|
|
|
aliases:
|
|
|
|
- vs
|
|
|
|
- vs
|
|
|
@ -65,70 +58,49 @@ options:
|
|
|
|
- Port of the virtual server. Required when state=present and vs does
|
|
|
|
- Port of the virtual server. Required when state=present and vs does
|
|
|
|
not exist. If you specify a value for this field, it must be a number
|
|
|
|
not exist. If you specify a value for this field, it must be a number
|
|
|
|
between 0 and 65535.
|
|
|
|
between 0 and 65535.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
all_profiles:
|
|
|
|
all_profiles:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of all Profiles (HTTP,ClientSSL,ServerSSL,etc) that must be used
|
|
|
|
- List of all Profiles (HTTP,ClientSSL,ServerSSL,etc) that must be used
|
|
|
|
by the virtual server
|
|
|
|
by the virtual server.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
all_policies:
|
|
|
|
all_policies:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of all policies enabled for the virtual server.
|
|
|
|
- List of all policies enabled for the virtual server.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
version_added: "2.3"
|
|
|
|
all_rules:
|
|
|
|
all_rules:
|
|
|
|
version_added: "2.2"
|
|
|
|
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of rules to be applied in priority order
|
|
|
|
- List of rules to be applied in priority order.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
enabled_vlans:
|
|
|
|
|
|
|
|
version_added: "2.2"
|
|
|
|
version_added: "2.2"
|
|
|
|
|
|
|
|
enabled_vlans:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- List of vlans to be enabled. When a VLAN named C(ALL) is used, all
|
|
|
|
- List of vlans to be enabled. When a VLAN named C(ALL) is used, all
|
|
|
|
VLANs will be allowed.
|
|
|
|
VLANs will be allowed.
|
|
|
|
required: false
|
|
|
|
version_added: "2.2"
|
|
|
|
default: None
|
|
|
|
|
|
|
|
pool:
|
|
|
|
pool:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Default pool for the virtual server
|
|
|
|
- Default pool for the virtual server.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
snat:
|
|
|
|
snat:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Source network address policy
|
|
|
|
- Source network address policy.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
choices:
|
|
|
|
choices:
|
|
|
|
- None
|
|
|
|
- None
|
|
|
|
- Automap
|
|
|
|
- Automap
|
|
|
|
- Name of a SNAT pool (eg "/Common/snat_pool_name") to enable SNAT with the specific pool
|
|
|
|
- Name of a SNAT pool (eg "/Common/snat_pool_name") to enable SNAT with the specific pool
|
|
|
|
default: None
|
|
|
|
|
|
|
|
default_persistence_profile:
|
|
|
|
default_persistence_profile:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Default Profile which manages the session persistence
|
|
|
|
- Default Profile which manages the session persistence.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
fallback_persistence_profile:
|
|
|
|
fallback_persistence_profile:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specifies the persistence profile you want the system to use if it
|
|
|
|
- Specifies the persistence profile you want the system to use if it
|
|
|
|
cannot use the specified default persistence profile.
|
|
|
|
cannot use the specified default persistence profile.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
version_added: "2.3"
|
|
|
|
route_advertisement_state:
|
|
|
|
route_advertisement_state:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Enable route advertisement for destination
|
|
|
|
- Enable route advertisement for destination.
|
|
|
|
required: false
|
|
|
|
choices: [ disabled, enabled ]
|
|
|
|
default: disabled
|
|
|
|
|
|
|
|
version_added: "2.3"
|
|
|
|
version_added: "2.3"
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Virtual server description
|
|
|
|
- Virtual server description.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: None
|
|
|
|
|
|
|
|
extends_documentation_fragment: f5
|
|
|
|
extends_documentation_fragment: f5
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -184,6 +156,10 @@ deleted:
|
|
|
|
sample: "my-virtual-server"
|
|
|
|
sample: "my-virtual-server"
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# import module snippets
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
|
|
|
|
from ansible.module_utils.f5_utils import *
|
|
|
|
|
|
|
|
|
|
|
|
# map of state values
|
|
|
|
# map of state values
|
|
|
|
STATES = {
|
|
|
|
STATES = {
|
|
|
|
'enabled': 'STATE_ENABLED',
|
|
|
|
'enabled': 'STATE_ENABLED',
|
|
|
@ -654,7 +630,7 @@ def set_route_advertisement_state(api, destination, partition, route_advertiseme
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
state = "STATE_%s" % route_advertisement_state.strip().upper()
|
|
|
|
state = "STATE_%s" % route_advertisement_state.strip().upper()
|
|
|
|
address = fq_name(partition, destination,)
|
|
|
|
address = fq_name(partition, destination,)
|
|
|
|
current_route_advertisement_state = get_route_advertisement_status(api,address)
|
|
|
|
current_route_advertisement_state = get_route_advertisement_status(api, address)
|
|
|
|
if current_route_advertisement_state != route_advertisement_state:
|
|
|
|
if current_route_advertisement_state != route_advertisement_state:
|
|
|
|
api.LocalLB.VirtualAddressV2.set_route_advertisement_state(virtual_addresses=[address], states=[state])
|
|
|
|
api.LocalLB.VirtualAddressV2.set_route_advertisement_state(virtual_addresses=[address], states=[state])
|
|
|
|
updated = True
|
|
|
|
updated = True
|
|
|
@ -666,25 +642,20 @@ def set_route_advertisement_state(api, destination, partition, route_advertiseme
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
argument_spec = f5_argument_spec()
|
|
|
|
argument_spec = f5_argument_spec()
|
|
|
|
argument_spec.update(dict(
|
|
|
|
argument_spec.update(dict(
|
|
|
|
state=dict(type='str', default='present',
|
|
|
|
state=dict(type='str', default='present', choices=['absent', 'disabled', 'enabled', 'present']),
|
|
|
|
choices=['present', 'absent', 'disabled', 'enabled']),
|
|
|
|
|
|
|
|
name=dict(type='str', required=True, aliases=['vs']),
|
|
|
|
name=dict(type='str', required=True, aliases=['vs']),
|
|
|
|
destination=dict(type='str', aliases=['address', 'ip']),
|
|
|
|
destination=dict(type='str', aliases=['address', 'ip']),
|
|
|
|
port=dict(type='str', default=None),
|
|
|
|
port=dict(type='str'),
|
|
|
|
all_policies=dict(type='list'),
|
|
|
|
all_policies=dict(type='list'),
|
|
|
|
all_profiles=dict(type='list', default=None),
|
|
|
|
all_profiles=dict(type='list'),
|
|
|
|
all_rules=dict(type='list'),
|
|
|
|
all_rules=dict(type='list'),
|
|
|
|
enabled_vlans=dict(type='list'),
|
|
|
|
enabled_vlans=dict(type='list'),
|
|
|
|
pool=dict(type='str'),
|
|
|
|
pool=dict(type='str'),
|
|
|
|
description=dict(type='str'),
|
|
|
|
description=dict(type='str'),
|
|
|
|
snat=dict(type='str'),
|
|
|
|
snat=dict(type='str'),
|
|
|
|
route_advertisement_state=dict(
|
|
|
|
route_advertisement_state=dict(type='str', choices=['disabled', 'enabled']),
|
|
|
|
type='str',
|
|
|
|
|
|
|
|
default=None,
|
|
|
|
|
|
|
|
choices=['enabled', 'disabled']
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
default_persistence_profile=dict(type='str'),
|
|
|
|
default_persistence_profile=dict(type='str'),
|
|
|
|
fallback_persistence_profile=dict(type='str')
|
|
|
|
fallback_persistence_profile=dict(type='str'),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
@ -818,9 +789,6 @@ def main():
|
|
|
|
module.fail_json(msg="received exception: %s" % e)
|
|
|
|
module.fail_json(msg="received exception: %s" % e)
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
module.exit_json(**result)
|
|
|
|
# import module snippets
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
|
|
|
|
from ansible.module_utils.f5_utils import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|