Take review comments in accounts (pull request :582)
This commit is contained in:
parent
c51c36d8d7
commit
292e0a2275
1 changed files with 30 additions and 22 deletions
|
@ -25,7 +25,7 @@ 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.0"
|
version_added: "2.0"
|
||||||
author: Etienne Carriere
|
author: Etienne Carriere (@Etienne-Carriere)
|
||||||
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 http://devcentral.f5.com)"
|
||||||
|
@ -85,7 +85,7 @@ options:
|
||||||
aliases: ['vs']
|
aliases: ['vs']
|
||||||
destination:
|
destination:
|
||||||
description:
|
description:
|
||||||
- "Destination IP of the virtual server (only host is currently supported) . Required when state=present and vs does not exist. Error when state=absent."
|
- "Destination IP of the virtual server (only host is currently supported) . Required when state=present and vs does not exist."
|
||||||
required: true
|
required: true
|
||||||
default: null
|
default: null
|
||||||
choices: []
|
choices: []
|
||||||
|
@ -93,24 +93,18 @@ options:
|
||||||
port:
|
port:
|
||||||
description:
|
description:
|
||||||
- "Port of the virtual server . Required when state=present and vs does not exist"
|
- "Port of the virtual server . Required when state=present and vs does not exist"
|
||||||
required: true
|
required: false
|
||||||
default: null
|
default: None
|
||||||
choices: []
|
|
||||||
aliases: []
|
|
||||||
all_profiles:
|
all_profiles:
|
||||||
description:
|
description:
|
||||||
- "List of all Profiles (HTTP,ClientSSL,ServerSSL,etc) that must be used by the virtual server"
|
- "List of all Profiles (HTTP,ClientSSL,ServerSSL,etc) that must be used by the virtual server"
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: None
|
||||||
choices: []
|
|
||||||
aliases: []
|
|
||||||
pool:
|
pool:
|
||||||
description:
|
description:
|
||||||
- "Default pool for the virtual server"
|
- "Default pool for the virtual server"
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: None
|
||||||
choices: []
|
|
||||||
aliases: []
|
|
||||||
snat:
|
snat:
|
||||||
description:
|
description:
|
||||||
- "Source network address policy"
|
- "Source network address policy"
|
||||||
|
@ -125,8 +119,7 @@ options:
|
||||||
description:
|
description:
|
||||||
- "Virtual server description."
|
- "Virtual server description."
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: None
|
||||||
choices: []
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -145,7 +138,7 @@ EXAMPLES = '''
|
||||||
state: present
|
state: present
|
||||||
partition: MyPartition
|
partition: MyPartition
|
||||||
name: myvirtualserver
|
name: myvirtualserver
|
||||||
destination: "{{ ansible_default_ipv4["address"] }}"
|
destination: "{{ ansible_default_ipv4['address'] }}"
|
||||||
port: 443
|
port: 443
|
||||||
pool: "{{ mypool }}"
|
pool: "{{ mypool }}"
|
||||||
snat: Automap
|
snat: Automap
|
||||||
|
@ -218,7 +211,7 @@ def vs_create(api,name,destination,port,pool):
|
||||||
profiles = _profiles)
|
profiles = _profiles)
|
||||||
created = True
|
created = True
|
||||||
return created
|
return created
|
||||||
except bigsudsOperationFailed, e :
|
except bigsuds.OperationFailed, e:
|
||||||
if "already exists" not in str(e):
|
if "already exists" not in str(e):
|
||||||
raise Exception('Error on creating Virtual Server : %s' % e)
|
raise Exception('Error on creating Virtual Server : %s' % e)
|
||||||
|
|
||||||
|
@ -259,7 +252,7 @@ def set_snat(api,name,snat):
|
||||||
try:
|
try:
|
||||||
current_state=get_snat_type(api,name)
|
current_state=get_snat_type(api,name)
|
||||||
if snat is None:
|
if snat is None:
|
||||||
return update
|
return updated
|
||||||
if snat == 'None' and current_state != 'SRC_TRANS_NONE':
|
if snat == 'None' and current_state != 'SRC_TRANS_NONE':
|
||||||
api.LocalLB.VirtualServer.set_source_address_translation_none(virtual_servers = [name])
|
api.LocalLB.VirtualServer.set_source_address_translation_none(virtual_servers = [name])
|
||||||
updated = True
|
updated = True
|
||||||
|
@ -292,18 +285,30 @@ def set_pool(api,name,pool):
|
||||||
def get_destination(api,name):
|
def get_destination(api,name):
|
||||||
return api.LocalLB.VirtualServer.get_destination_v2(virtual_servers = [name])[0]
|
return api.LocalLB.VirtualServer.get_destination_v2(virtual_servers = [name])[0]
|
||||||
|
|
||||||
def set_destination(api,name,destination,port):
|
def set_destination(api,name,destination):
|
||||||
updated=False
|
updated=False
|
||||||
try:
|
try:
|
||||||
current_destination = get_destination(api,name)
|
current_destination = get_destination(api,name)
|
||||||
if (destination is not None and port is not None) and (destination != current_destination['address'] or port != current_destination['port']):
|
if destination is not None and destination != current_destination['address']:
|
||||||
api.LocalLB.VirtualServer.set_destination_v2(virtual_servers = [name],destinations=[{'address': destination, 'port':port}])
|
api.LocalLB.VirtualServer.set_destination_v2(virtual_servers = [name],destinations=[{'address': destination, 'port': current_destination['port']}])
|
||||||
updated=True
|
updated=True
|
||||||
return updated
|
return updated
|
||||||
except bigsuds.OperationFailed, e:
|
except bigsuds.OperationFailed, e:
|
||||||
raise Exception('Error on setting destination : %s'% e )
|
raise Exception('Error on setting destination : %s'% e )
|
||||||
|
|
||||||
|
|
||||||
|
def set_port(api,name,port):
|
||||||
|
updated=False
|
||||||
|
try:
|
||||||
|
current_destination = get_destination(api,name)
|
||||||
|
if port is not None and port != current_destination['port']:
|
||||||
|
api.LocalLB.VirtualServer.set_destination_v2(virtual_servers = [name],destinations=[{'address': current_destination['address'], 'port': port}])
|
||||||
|
updated=True
|
||||||
|
return updated
|
||||||
|
except bigsuds.OperationFailed, e:
|
||||||
|
raise Exception('Error on setting port : %s'% e )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_description(api,name):
|
def get_description(api,name):
|
||||||
return api.LocalLB.VirtualServer.get_description(virtual_servers = [name])[0]
|
return api.LocalLB.VirtualServer.get_description(virtual_servers = [name])[0]
|
||||||
|
@ -428,7 +433,8 @@ def main():
|
||||||
# Have a transaction for all the changes
|
# Have a transaction for all the changes
|
||||||
try:
|
try:
|
||||||
api.System.Session.start_transaction()
|
api.System.Session.start_transaction()
|
||||||
result['changed']|=set_destination(api,name,fq_name(partition,destination),port)
|
result['changed']|=set_destination(api,name,fq_name(partition,destination))
|
||||||
|
result['changed']|=set_port(api,name,port)
|
||||||
result['changed']|=set_pool(api,name,pool)
|
result['changed']|=set_pool(api,name,pool)
|
||||||
result['changed']|=set_description(api,name,description)
|
result['changed']|=set_description(api,name,description)
|
||||||
result['changed']|=set_snat(api,name,snat)
|
result['changed']|=set_snat(api,name,snat)
|
||||||
|
@ -458,5 +464,7 @@ def main():
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.f5 import *
|
from ansible.module_utils.f5 import *
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue