From 06f76d640734ee4f221967d1ab6f6fc9affb3627 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Fri, 11 May 2018 17:12:17 -0700 Subject: [PATCH] Removes ignores for f5 (#40038) Removes ignores for f5 from unit tests and fixes any issues that are being suppressed by the ignores --- .../modules/network/f5/bigip_asm_policy.py | 1 + .../modules/network/f5/bigip_command.py | 3 + .../modules/network/f5/bigip_config.py | 14 ++--- .../modules/network/f5/bigip_device_dns.py | 9 +-- .../modules/network/f5/bigip_device_group.py | 1 + .../modules/network/f5/bigip_device_httpd.py | 7 +-- .../modules/network/f5/bigip_device_ntp.py | 1 - .../modules/network/f5/bigip_device_sshd.py | 7 +-- lib/ansible/modules/network/f5/bigip_facts.py | 62 +++++++++++++------ .../modules/network/f5/bigip_gtm_pool.py | 2 + .../modules/network/f5/bigip_gtm_server.py | 22 +++++-- .../modules/network/f5/bigip_iapp_service.py | 4 +- .../network/f5/bigip_monitor_snmp_dca.py | 2 +- .../modules/network/f5/bigip_policy.py | 1 + .../network/f5/bigip_profile_client_ssl.py | 4 +- .../modules/network/f5/bigip_selfip.py | 3 +- .../modules/network/f5/bigip_sys_global.py | 13 ++-- .../network/f5/bigip_virtual_server.py | 9 ++- test/sanity/validate-modules/ignore.txt | 22 ------- 19 files changed, 101 insertions(+), 86 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_asm_policy.py b/lib/ansible/modules/network/f5/bigip_asm_policy.py index 57ebbc722f..32ca47f921 100644 --- a/lib/ansible/modules/network/f5/bigip_asm_policy.py +++ b/lib/ansible/modules/network/f5/bigip_asm_policy.py @@ -42,6 +42,7 @@ options: choices: - present - absent + default: present file: description: - Full path to a policy file to be imported into the BIG-IP ASM. diff --git a/lib/ansible/modules/network/f5/bigip_command.py b/lib/ansible/modules/network/f5/bigip_command.py index c3e2cc84bd..9b11b9bf7d 100644 --- a/lib/ansible/modules/network/f5/bigip_command.py +++ b/lib/ansible/modules/network/f5/bigip_command.py @@ -55,6 +55,9 @@ options: then all conditionals in the I(wait_for) must be satisfied. If the value is set to C(any) then only one of the values must be satisfied. + choices: + - any + - all default: all retries: description: diff --git a/lib/ansible/modules/network/f5/bigip_config.py b/lib/ansible/modules/network/f5/bigip_config.py index 5b2e1d5e4f..c2bc9e8da2 100644 --- a/lib/ansible/modules/network/f5/bigip_config.py +++ b/lib/ansible/modules/network/f5/bigip_config.py @@ -29,13 +29,13 @@ options: save: description: - The C(save) argument instructs the module to save the - running-config to startup-config. This operation is performed - after any changes are made to the current running config. If - no changes are made, the configuration is still saved to the - startup config. This option will always cause the module to - return changed. + running-config to startup-config. + - This operation is performed after any changes are made to the + current running config. If no changes are made, the configuration + is still saved to the startup config. + - This option will always cause the module to return changed. type: bool - default: no + default: yes reset: description: - Loads the default configuration on the device. @@ -323,7 +323,7 @@ class ArgumentSpec(object): ), save=dict( type='bool', - default=True + default='yes' ) ) self.argument_spec = {} diff --git a/lib/ansible/modules/network/f5/bigip_device_dns.py b/lib/ansible/modules/network/f5/bigip_device_dns.py index 42aef16b2a..58e9a8df7e 100644 --- a/lib/ansible/modules/network/f5/bigip_device_dns.py +++ b/lib/ansible/modules/network/f5/bigip_device_dns.py @@ -26,10 +26,11 @@ options: operation each time a lookup is needed. Please note that this applies only to Access Policy Manager features, such as ACLs, web application rewrites, and authentication. - default: disable choices: - enabled - disabled + - enable + - disable name_servers: description: - A list of name servers that the system uses to validate DNS lookups @@ -320,18 +321,12 @@ class ArgumentSpec(object): choices=['disabled', 'enabled', 'disable', 'enable'] ), name_servers=dict( - required=False, - default=None, type='list' ), search=dict( - required=False, - default=None, type='list' ), ip_version=dict( - required=False, - default=None, choices=[4, 6], type='int' ), diff --git a/lib/ansible/modules/network/f5/bigip_device_group.py b/lib/ansible/modules/network/f5/bigip_device_group.py index 7bd9e5dfc9..e050e6d031 100644 --- a/lib/ansible/modules/network/f5/bigip_device_group.py +++ b/lib/ansible/modules/network/f5/bigip_device_group.py @@ -83,6 +83,7 @@ options: choices: - present - absent + default: present notes: - This module is primarily used as a component of configuring HA pairs of BIG-IP devices. diff --git a/lib/ansible/modules/network/f5/bigip_device_httpd.py b/lib/ansible/modules/network/f5/bigip_device_httpd.py index c87a0fe3fa..039aae7905 100644 --- a/lib/ansible/modules/network/f5/bigip_device_httpd.py +++ b/lib/ansible/modules/network/f5/bigip_device_httpd.py @@ -25,10 +25,9 @@ options: description: - Specifies, if you have enabled HTTPD access, the IP address or address range for other systems that can communicate with this system. - choices: - - all - - IP address, such as 172.27.1.10 - - IP range, such as 172.27.*.* or 172.27.0.0/255.255.0.0 + - To specify all addresses, use the value C(all). + - IP address can be specified, such as 172.27.1.10. + - IP rangees can be specified, such as 172.27.*.* or 172.27.0.0/255.255.0.0. auth_name: description: - Sets the BIG-IP authentication realm name. diff --git a/lib/ansible/modules/network/f5/bigip_device_ntp.py b/lib/ansible/modules/network/f5/bigip_device_ntp.py index 32cc50d327..1147e9f169 100644 --- a/lib/ansible/modules/network/f5/bigip_device_ntp.py +++ b/lib/ansible/modules/network/f5/bigip_device_ntp.py @@ -36,7 +36,6 @@ options: description: - The timezone to set for NTP lookups. At least one of C(ntp_servers) or C(timezone) is required. - default: UTC extends_documentation_fragment: f5 author: - Tim Rupp (@caphrim007) diff --git a/lib/ansible/modules/network/f5/bigip_device_sshd.py b/lib/ansible/modules/network/f5/bigip_device_sshd.py index 68591be02f..1a6cadca22 100644 --- a/lib/ansible/modules/network/f5/bigip_device_sshd.py +++ b/lib/ansible/modules/network/f5/bigip_device_sshd.py @@ -24,10 +24,9 @@ options: - Specifies, if you have enabled SSH access, the IP address or address range for other systems that can use SSH to communicate with this system. - choices: - - all - - IP address, such as 172.27.1.10 - - IP range, such as 172.27.*.* or 172.27.0.0/255.255.0.0 + - To specify all addresses, use the value C(all). + - IP address can be specified, such as 172.27.1.10. + - IP rangees can be specified, such as 172.27.*.* or 172.27.0.0/255.255.0.0. banner: description: - Whether to enable the banner or not. diff --git a/lib/ansible/modules/network/f5/bigip_facts.py b/lib/ansible/modules/network/f5/bigip_facts.py index ce97390bda..ee97eafb2b 100644 --- a/lib/ansible/modules/network/f5/bigip_facts.py +++ b/lib/ansible/modules/network/f5/bigip_facts.py @@ -19,7 +19,7 @@ module: bigip_facts short_description: Collect facts from F5 BIG-IP devices description: - Collect facts from F5 BIG-IP devices via iControl SOAP API -version_added: "1.6" +version_added: 1.6 author: - Matt Hite (@mhite) - Tim Rupp (@caphrim007) @@ -36,12 +36,12 @@ options: description: - BIG-IP session support; may be useful to avoid concurrency issues in certain circumstances. + default: no type: bool - default: 'yes' include: description: - Fact category or list of categories to collect - required: true + required: True choices: - address_class - certificate @@ -83,20 +83,22 @@ import fnmatch import re import traceback +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.six import string_types +from ansible.module_utils.six.moves import map, zip + +try: + from library.module_utils.network.f5.legacy import bigip_api, bigsuds_found + from library.module_utils.network.f5.common import f5_argument_spec +except ImportError: + from ansible.module_utils.network.f5.legacy import bigip_api, bigsuds_found + from ansible.module_utils.network.f5.common import f5_argument_spec + try: from suds import MethodNotFound, WebFault except ImportError: pass # Handle via f5_utils.bigsuds_found -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.f5_utils import bigip_api, bigsuds_found -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): """F5 iControl class. @@ -1089,6 +1091,9 @@ class AddressClasses(object): F5 BIG-IP address group/class class. + In TMUI these things are known as Address Data Groups. Examples that ship with the + box include /Common/aol and /Common/private_net + Attributes: api: iControl API instance. address_classes: List of address classes. @@ -1107,7 +1112,15 @@ class AddressClasses(object): def get_address_class(self): key = self.api.LocalLB.Class.get_address_class(self.address_classes) value = self.api.LocalLB.Class.get_address_class_member_data_value(key) - result = list(map(zip, [x['members'] for x in key], value)) + + result = [] + for idx, v in enumerate(key): + for idx2, member in enumerate(v['members']): + dg_value = dict( + value=value[idx][idx2] + ) + dg_value.update(member) + result.append(dg_value) return result def get_description(self): @@ -1639,9 +1652,18 @@ def generate_provision_dict(f5): def main(): argument_spec = f5_argument_spec meta_args = dict( - session=dict(type='bool', default=False), - include=dict(type='list', required=True), - filter=dict(type='str', required=False), + session=dict(type='bool', default='no'), + include=dict( + type='raw', + required=True, + choices=[ + 'address_class', 'certificate', 'client_ssl_profile', 'device', + 'device_group', 'interface', 'key', 'node', 'pool', 'provision', + 'rule', 'self_ip', 'software', 'system_info', 'traffic_group', + 'trunk', 'virtual_address', 'virtual_server', 'vlan' + ] + ), + filter=dict(type='str'), ) argument_spec.update(meta_args) @@ -1671,7 +1693,11 @@ def main(): regex = fnmatch.translate(fact_filter) else: regex = None - include = [x.lower() for x in module.params['include']] + if isinstance(module.params['include'], string_types): + includes = module.params['include'].split(',') + else: + includes = module.params['include'] + include = [x.lower() for x in includes] valid_includes = ('address_class', 'certificate', 'client_ssl_profile', 'device', 'device_group', 'interface', 'key', 'node', 'pool', 'provision', 'rule', 'self_ip', 'software', @@ -1679,7 +1705,7 @@ def main(): 'virtual_address', 'virtual_server', 'vlan') include_test = (x in valid_includes for x in include) if not all(include_test): - module.fail_json(msg="value of include must be one or more of: %s, got: %s" % (",".join(valid_includes), ",".join(include))) + module.fail_json(msg="Value of include must be one or more of: %s, got: %s" % (",".join(valid_includes), ",".join(include))) try: facts = {} diff --git a/lib/ansible/modules/network/f5/bigip_gtm_pool.py b/lib/ansible/modules/network/f5/bigip_gtm_pool.py index c2e83ecc78..a7ccf20af0 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_pool.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_pool.py @@ -31,6 +31,7 @@ options: - absent - enabled - disabled + default: present preferred_lb_method: description: - The load balancing mode that the system tries first. @@ -94,6 +95,7 @@ options: - drop-packet - fallback-ip - virtual-server-score + - none fallback_ip: description: - Specifies the IPv4, or IPv6 address of the server to which the system diff --git a/lib/ansible/modules/network/f5/bigip_gtm_server.py b/lib/ansible/modules/network/f5/bigip_gtm_server.py index 8e63697163..db0388d9c4 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_server.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_server.py @@ -769,12 +769,22 @@ class ArgumentSpec(object): def __init__(self): self.states = ['absent', 'present', 'enabled', 'disabled'] self.server_types = [ - 'alteon-ace-director', 'cisco-css', 'cisco-server-load-balancer', - 'generic-host', 'radware-wsd', 'windows-nt-4.0', 'bigip', - 'cisco-local-director-v2', 'extreme', 'generic-load-balancer', - 'sun-solaris', 'cacheflow', 'cisco-local-director-v3', - 'foundry-server-iron', 'netapp', 'standalone-bigip', - 'redundant-bigip', 'windows-2000-server' + 'alteon-ace-director', + 'cisco-css', + 'cisco-server-load-balancer', + 'generic-host', + 'radware-wsd', + 'windows-nt-4.0', + 'bigip', + 'cisco-local-director-v2', + 'extreme', + 'generic-load-balancer', + 'sun-solaris', + 'cacheflow', + 'cisco-local-director-v3', + 'foundry-server-iron', + 'netapp', + 'windows-2000-server' ] self.supports_check_mode = True argument_spec = dict( diff --git a/lib/ansible/modules/network/f5/bigip_iapp_service.py b/lib/ansible/modules/network/f5/bigip_iapp_service.py index 0ff0d86ba3..8ac948d2e9 100644 --- a/lib/ansible/modules/network/f5/bigip_iapp_service.py +++ b/lib/ansible/modules/network/f5/bigip_iapp_service.py @@ -77,6 +77,7 @@ options: over any similar setting in the iApp Server payload that you provide in the C(parameters) field. default: yes + type: bool version_added: 2.5 traffic_group: description: @@ -618,7 +619,8 @@ class ArgumentSpec(object): type='bool' ), strict_updates=dict( - type='bool' + type='bool', + default='yes' ), traffic_group=dict(), partition=dict( diff --git a/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py b/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py index db6fb98b30..ea7f17ff82 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py @@ -598,7 +598,7 @@ class ArgumentSpec(object): timeout=dict(type='int'), time_until_up=dict(type='int'), community=dict(), - version=dict(), + version=dict(choices=['v1', 'v2c']), agent_type=dict( choices=['UCD', 'WIN2000', 'GENERIC'] ), diff --git a/lib/ansible/modules/network/f5/bigip_policy.py b/lib/ansible/modules/network/f5/bigip_policy.py index bf1af427c9..8254ed537e 100644 --- a/lib/ansible/modules/network/f5/bigip_policy.py +++ b/lib/ansible/modules/network/f5/bigip_policy.py @@ -47,6 +47,7 @@ options: - present - absent - draft + default: present strategy: description: - Specifies the method to determine which actions get executed in the diff --git a/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py b/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py index debee4af56..e49a7fe00b 100644 --- a/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py +++ b/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py @@ -29,7 +29,7 @@ options: - The parent template of this monitor template. Once this value has been set, it cannot be changed. By default, this value is the C(clientssl) parent on the C(Common) partition. - default: "/Common/clientssl" + default: /Common/clientssl ciphers: description: - Specifies the list of ciphers that the system supports. When creating a new @@ -480,7 +480,7 @@ class ArgumentSpec(object): self.supports_check_mode = True argument_spec = dict( name=dict(required=True), - parent=dict(), + parent=dict(default='/Common/clientssl'), ciphers=dict(), cert_key_chain=dict( type='list', diff --git a/lib/ansible/modules/network/f5/bigip_selfip.py b/lib/ansible/modules/network/f5/bigip_selfip.py index 744745585f..1756d9b5c5 100644 --- a/lib/ansible/modules/network/f5/bigip_selfip.py +++ b/lib/ansible/modules/network/f5/bigip_selfip.py @@ -34,8 +34,9 @@ options: name: description: - The self IP to create. + - If this parameter is not specified, then it will default to the value supplied + in the C(address) parameter. required: True - default: Value of C(address) netmask: description: - The netmask for the self IP. When creating a new Self IP, this value diff --git a/lib/ansible/modules/network/f5/bigip_sys_global.py b/lib/ansible/modules/network/f5/bigip_sys_global.py index ddaaac6ad2..90b03b7a5e 100644 --- a/lib/ansible/modules/network/f5/bigip_sys_global.py +++ b/lib/ansible/modules/network/f5/bigip_sys_global.py @@ -383,26 +383,25 @@ class ArgumentSpec(object): def __init__(self): self.supports_check_mode = True self.states = ['present'] - self.on_off_choices = ['enabled', 'disabled', 'True', 'False'] + list(BOOLEANS) argument_spec = dict( security_banner=dict( - choices=self.on_off_choices + type='bool' ), banner_text=dict(), gui_setup=dict( - choices=self.on_off_choices + type='bool' ), lcd_display=dict( - choices=self.on_off_choices + type='bool' ), mgmt_dhcp=dict( - choices=self.on_off_choices + type='bool' ), net_reboot=dict( - choices=self.on_off_choices + type='bool' ), quiet_boot=dict( - choices=self.on_off_choices + type='bool' ), console_timeout=dict(required=False, type='int', default=None), state=dict(default='present', choices=['present']) diff --git a/lib/ansible/modules/network/f5/bigip_virtual_server.py b/lib/ansible/modules/network/f5/bigip_virtual_server.py index 953640e65d..ac8bc66318 100644 --- a/lib/ansible/modules/network/f5/bigip_virtual_server.py +++ b/lib/ansible/modules/network/f5/bigip_virtual_server.py @@ -224,11 +224,10 @@ options: - When C(type) is C(dhcp), this parameter is ignored. - When C(type) is C(reject), this parameter will be ignored. - When C(type) is C(internal), this parameter will be ignored. - choices: - - None - - Automap - - Name of a SNAT pool (eg "/Common/snat_pool_name") to enable SNAT - with the specific pool + - The name of a SNAT pool (eg "/Common/snat_pool_name") can be specified to enable SNAT + with the specific pool. + - To remove SNAT, specify the word C(none). + - To specify automap, use the word C(automap). default_persistence_profile: description: - Default Profile which manages the session persistence. diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 281cbab555..5408345f8b 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -929,28 +929,6 @@ lib/ansible/modules/network/eos/eos_lldp.py E326 lib/ansible/modules/network/eos/eos_logging.py E326 lib/ansible/modules/network/eos/eos_vlan.py E325 lib/ansible/modules/network/eos/eos_vrf.py E325 -lib/ansible/modules/network/f5/bigip_asm_policy.py E324 -lib/ansible/modules/network/f5/bigip_command.py E326 -lib/ansible/modules/network/f5/bigip_config.py E324 -lib/ansible/modules/network/f5/bigip_device_dns.py E324 -lib/ansible/modules/network/f5/bigip_device_dns.py E326 -lib/ansible/modules/network/f5/bigip_device_group.py E324 -lib/ansible/modules/network/f5/bigip_device_httpd.py E326 -lib/ansible/modules/network/f5/bigip_device_ntp.py E324 -lib/ansible/modules/network/f5/bigip_device_sshd.py E326 -lib/ansible/modules/network/f5/bigip_facts.py E324 -lib/ansible/modules/network/f5/bigip_facts.py E326 -lib/ansible/modules/network/f5/bigip_gtm_pool.py E324 -lib/ansible/modules/network/f5/bigip_gtm_pool.py E326 -lib/ansible/modules/network/f5/bigip_gtm_server.py E326 -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_profile_client_ssl.py E324 -lib/ansible/modules/network/f5/bigip_selfip.py E324 -lib/ansible/modules/network/f5/bigip_sys_global.py E326 -lib/ansible/modules/network/f5/bigip_virtual_server.py E326 lib/ansible/modules/network/fortimanager/fmgr_script.py E324 lib/ansible/modules/network/fortios/fortios_address.py E324 lib/ansible/modules/network/illumos/dladm_iptun.py E325