diff --git a/lib/ansible/modules/network/netscaler/netscaler_lb_monitor.py b/lib/ansible/modules/network/netscaler/netscaler_lb_monitor.py new file mode 100644 index 0000000000..320c7d8756 --- /dev/null +++ b/lib/ansible/modules/network/netscaler/netscaler_lb_monitor.py @@ -0,0 +1,1390 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2017 Citrix Systems +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + + +ANSIBLE_METADATA = {'status': ['preview'], + 'supported_by': 'community', + 'metadata_version': '1.0'} + + +DOCUMENTATION = ''' +module: netscaler_lb_monitor +short_description: Manage load balancing monitors +description: + - Manage load balancing monitors. + - This module is intended to run either on the ansible control node or a bastion (jumpserver) with access to the actual netscaler instance. + +version_added: "2.4.0" + +author: George Nikolopoulos (@giorgos-nikolopoulos) + +options: + + monitorname: + description: + - >- + Name for the monitor. Must begin with an ASCII alphanumeric or underscore C(_) character, and must + contain only ASCII alphanumeric, underscore, hash C(#), period C(.), space C( ), colon C(:), at C(@), equals + C(=), and hyphen C(-) characters. + - "Minimum length = 1" + + type: + choices: + - 'PING' + - 'TCP' + - 'HTTP' + - 'TCP-ECV' + - 'HTTP-ECV' + - 'UDP-ECV' + - 'DNS' + - 'FTP' + - 'LDNS-PING' + - 'LDNS-TCP' + - 'LDNS-DNS' + - 'RADIUS' + - 'USER' + - 'HTTP-INLINE' + - 'SIP-UDP' + - 'SIP-TCP' + - 'LOAD' + - 'FTP-EXTENDED' + - 'SMTP' + - 'SNMP' + - 'NNTP' + - 'MYSQL' + - 'MYSQL-ECV' + - 'MSSQL-ECV' + - 'ORACLE-ECV' + - 'LDAP' + - 'POP3' + - 'CITRIX-XML-SERVICE' + - 'CITRIX-WEB-INTERFACE' + - 'DNS-TCP' + - 'RTSP' + - 'ARP' + - 'CITRIX-AG' + - 'CITRIX-AAC-LOGINPAGE' + - 'CITRIX-AAC-LAS' + - 'CITRIX-XD-DDC' + - 'ND6' + - 'CITRIX-WI-EXTENDED' + - 'DIAMETER' + - 'RADIUS_ACCOUNTING' + - 'STOREFRONT' + - 'APPC' + - 'SMPP' + - 'CITRIX-XNC-ECV' + - 'CITRIX-XDM' + - 'CITRIX-STA-SERVICE' + - 'CITRIX-STA-SERVICE-NHOP' + description: + - "Type of monitor that you want to create." + + action: + choices: + - 'NONE' + - 'LOG' + - 'DOWN' + description: + - >- + Action to perform when the response to an inline monitor (a monitor of type C(HTTP-INLINE)) indicates + that the service is down. A service monitored by an inline monitor is considered C(DOWN) if the response + code is not one of the codes that have been specified for the Response Code parameter. + - "Available settings function as follows:" + - >- + * C(NONE) - Do not take any action. However, the show service command and the show lb monitor command + indicate the total number of responses that were checked and the number of consecutive error + responses received after the last successful probe. + - "* C(LOG) - Log the event in NSLOG or SYSLOG." + - >- + * C(DOWN) - Mark the service as being down, and then do not direct any traffic to the service until the + configured down time has expired. Persistent connections to the service are terminated as soon as the + service is marked as C(DOWN). Also, log the event in NSLOG or SYSLOG. + + respcode: + description: + - >- + Response codes for which to mark the service as UP. For any other response code, the action performed + depends on the monitor type. C(HTTP) monitors and C(RADIUS) monitors mark the service as C(DOWN), while + C(HTTP-INLINE) monitors perform the action indicated by the Action parameter. + + httprequest: + description: + - "HTTP request to send to the server (for example, C(\\"HEAD /file.html\\"))." + + rtsprequest: + description: + - "RTSP request to send to the server (for example, C(\\"OPTIONS *\\"))." + + customheaders: + description: + - "Custom header string to include in the monitoring probes." + + maxforwards: + description: + - >- + Maximum number of hops that the SIP request used for monitoring can traverse to reach the server. + Applicable only to monitors of type C(SIP-UDP). + - "Minimum value = C(0)" + - "Maximum value = C(255)" + + sipmethod: + choices: + - 'OPTIONS' + - 'INVITE' + - 'REGISTER' + description: + - "SIP method to use for the query. Applicable only to monitors of type C(SIP-UDP)." + + sipuri: + description: + - >- + SIP URI string to send to the service (for example, C(sip:sip.test)). Applicable only to monitors of + type C(SIP-UDP). + - "Minimum length = 1" + + sipreguri: + description: + - >- + SIP user to be registered. Applicable only if the monitor is of type C(SIP-UDP) and the SIP Method + parameter is set to C(REGISTER). + - "Minimum length = 1" + + send: + description: + - "String to send to the service. Applicable to C(TCP-ECV), C(HTTP-ECV), and C(UDP-ECV) monitors." + + recv: + description: + - >- + String expected from the server for the service to be marked as UP. Applicable to C(TCP-ECV), C(HTTP-ECV), + and C(UDP-ECV) monitors. + + query: + description: + - "Domain name to resolve as part of monitoring the DNS service (for example, C(example.com))." + + querytype: + choices: + - 'Address' + - 'Zone' + - 'AAAA' + description: + - >- + Type of DNS record for which to send monitoring queries. Set to C(Address) for querying A records, C(AAAA) + for querying AAAA records, and C(Zone) for querying the SOA record. + + scriptname: + description: + - >- + Path and name of the script to execute. The script must be available on the NetScaler appliance, in + the /nsconfig/monitors/ directory. + - "Minimum length = 1" + + scriptargs: + description: + - "String of arguments for the script. The string is copied verbatim into the request." + + dispatcherip: + description: + - "IP address of the dispatcher to which to send the probe." + + dispatcherport: + description: + - "Port number on which the dispatcher listens for the monitoring probe." + + username: + description: + - >- + User name with which to probe the C(RADIUS), C(NNTP), C(FTP), C(FTP-EXTENDED), C(MYSQL), C(MSSQL), C(POP3), C(CITRIX-AG), + C(CITRIX-XD-DDC), C(CITRIX-WI-EXTENDED), C(CITRIX-XNC) or C(CITRIX-XDM) server. + - "Minimum length = 1" + + password: + description: + - >- + Password that is required for logging on to the C(RADIUS), C(NNTP), C(FTP), C(FTP-EXTENDED), C(MYSQL), C(MSSQL), C(POP3), + C(CITRIX-AG), C(CITRIX-XD-DDC), C(CITRIX-WI-EXTENDED), C(CITRIX-XNC-ECV) or C(CITRIX-XDM) server. Used in + conjunction with the user name specified for the C(username) parameter. + - "Minimum length = 1" + + secondarypassword: + description: + - >- + Secondary password that users might have to provide to log on to the Access Gateway server. + Applicable to C(CITRIX-AG) monitors. + + logonpointname: + description: + - >- + Name of the logon point that is configured for the Citrix Access Gateway Advanced Access Control + software. Required if you want to monitor the associated login page or Logon Agent. Applicable to + C(CITRIX-AAC-LAS) and C(CITRIX-AAC-LOGINPAGE) monitors. + + lasversion: + description: + - >- + Version number of the Citrix Advanced Access Control Logon Agent. Required by the C(CITRIX-AAC-LAS) + monitor. + + radkey: + description: + - >- + Authentication key (shared secret text string) for RADIUS clients and servers to exchange. Applicable + to monitors of type C(RADIUS) and C(RADIUS_ACCOUNTING). + - "Minimum length = 1" + + radnasid: + description: + - "NAS-Identifier to send in the Access-Request packet. Applicable to monitors of type C(RADIUS)." + - "Minimum length = 1" + + radnasip: + description: + - >- + Network Access Server (NAS) IP address to use as the source IP address when monitoring a RADIUS + server. Applicable to monitors of type C(RADIUS) and C(RADIUS_ACCOUNTING). + + radaccounttype: + description: + - "Account Type to be used in Account Request Packet. Applicable to monitors of type C(RADIUS_ACCOUNTING)." + - "Minimum value = 0" + - "Maximum value = 15" + + radframedip: + description: + - "Source ip with which the packet will go out . Applicable to monitors of type C(RADIUS_ACCOUNTING)." + + radapn: + description: + - >- + Called Station Id to be used in Account Request Packet. Applicable to monitors of type + C(RADIUS_ACCOUNTING). + - "Minimum length = 1" + + radmsisdn: + description: + - >- + Calling Stations Id to be used in Account Request Packet. Applicable to monitors of type + C(RADIUS_ACCOUNTING). + - "Minimum length = 1" + + radaccountsession: + description: + - >- + Account Session ID to be used in Account Request Packet. Applicable to monitors of type + C(RADIUS_ACCOUNTING). + - "Minimum length = 1" + + lrtm: + choices: + - 'ENABLED' + - 'DISABLED' + description: + - >- + Calculate the least response times for bound services. If this parameter is not enabled, the + appliance does not learn the response times of the bound services. Also used for LRTM load balancing. + + deviation: + description: + - >- + Time value added to the learned average response time in dynamic response time monitoring (DRTM). + When a deviation is specified, the appliance learns the average response time of bound services and + adds the deviation to the average. The final value is then continually adjusted to accommodate + response time variations over time. Specified in milliseconds, seconds, or minutes. + - "Minimum value = C(0)" + - "Maximum value = C(20939)" + + units1: + choices: + - 'SEC' + - 'MSEC' + - 'MIN' + description: + - "Unit of measurement for the Deviation parameter. Cannot be changed after the monitor is created." + + interval: + description: + - "Time interval between two successive probes. Must be greater than the value of Response Time-out." + - "Minimum value = C(1)" + - "Maximum value = C(20940)" + + units3: + choices: + - 'SEC' + - 'MSEC' + - 'MIN' + description: + - "monitor interval units." + + resptimeout: + description: + - >- + Amount of time for which the appliance must wait before it marks a probe as FAILED. Must be less than + the value specified for the Interval parameter. + - >- + Note: For C(UDP-ECV) monitors for which a receive string is not configured, response timeout does not + apply. For C(UDP-ECV) monitors with no receive string, probe failure is indicated by an ICMP port + unreachable error received from the service. + - "Minimum value = C(1)" + - "Maximum value = C(20939)" + + units4: + choices: + - 'SEC' + - 'MSEC' + - 'MIN' + description: + - "monitor response timeout units." + + resptimeoutthresh: + description: + - >- + Response time threshold, specified as a percentage of the Response Time-out parameter. If the + response to a monitor probe has not arrived when the threshold is reached, the appliance generates an + SNMP trap called monRespTimeoutAboveThresh. After the response time returns to a value below the + threshold, the appliance generates a monRespTimeoutBelowThresh SNMP trap. For the traps to be + generated, the "MONITOR-RTO-THRESHOLD" alarm must also be enabled. + - "Minimum value = C(0)" + - "Maximum value = C(100)" + + retries: + description: + - >- + Maximum number of probes to send to establish the state of a service for which a monitoring probe + failed. + - "Minimum value = C(1)" + - "Maximum value = C(127)" + + failureretries: + description: + - >- + Number of retries that must fail, out of the number specified for the Retries parameter, for a + service to be marked as DOWN. For example, if the Retries parameter is set to 10 and the Failure + Retries parameter is set to 6, out of the ten probes sent, at least six probes must fail if the + service is to be marked as DOWN. The default value of 0 means that all the retries must fail if the + service is to be marked as DOWN. + - "Minimum value = C(0)" + - "Maximum value = C(32)" + + alertretries: + description: + - >- + Number of consecutive probe failures after which the appliance generates an SNMP trap called + monProbeFailed. + - "Minimum value = C(0)" + - "Maximum value = C(32)" + + successretries: + description: + - "Number of consecutive successful probes required to transition a service's state from DOWN to UP." + - "Minimum value = C(1)" + - "Maximum value = C(32)" + + downtime: + description: + - >- + Time duration for which to wait before probing a service that has been marked as DOWN. Expressed in + milliseconds, seconds, or minutes. + - "Minimum value = C(1)" + - "Maximum value = C(20939)" + + units2: + choices: + - 'SEC' + - 'MSEC' + - 'MIN' + description: + - "Unit of measurement for the Down Time parameter. Cannot be changed after the monitor is created." + + destip: + description: + - >- + IP address of the service to which to send probes. If the parameter is set to 0, the IP address of + the server to which the monitor is bound is considered the destination IP address. + + destport: + description: + - >- + TCP or UDP port to which to send the probe. If the parameter is set to 0, the port number of the + service to which the monitor is bound is considered the destination port. For a monitor of type C(USER), + however, the destination port is the port number that is included in the HTTP request sent to the + dispatcher. Does not apply to monitors of type C(PING). + + state: + choices: + - 'ENABLED' + - 'DISABLED' + description: + - >- + State of the monitor. The C(DISABLED) setting disables not only the monitor being configured, but all + monitors of the same type, until the parameter is set to C(ENABLED). If the monitor is bound to a + service, the state of the monitor is not taken into account when the state of the service is + determined. + + reverse: + description: + - >- + Mark a service as DOWN, instead of UP, when probe criteria are satisfied, and as UP instead of DOWN + when probe criteria are not satisfied. + type: bool + + transparent: + description: + - >- + The monitor is bound to a transparent device such as a firewall or router. The state of a transparent + device depends on the responsiveness of the services behind it. If a transparent device is being + monitored, a destination IP address must be specified. The probe is sent to the specified IP address + by using the MAC address of the transparent device. + type: bool + + iptunnel: + description: + - >- + Send the monitoring probe to the service through an IP tunnel. A destination IP address must be + specified. + type: bool + + tos: + description: + - "Probe the service by encoding the destination IP address in the IP TOS (6) bits." + type: bool + + tosid: + description: + - "The TOS ID of the specified destination IP. Applicable only when the TOS parameter is set." + - "Minimum value = C(1)" + - "Maximum value = C(63)" + + secure: + description: + - >- + Use a secure SSL connection when monitoring a service. Applicable only to TCP based monitors. The + secure option cannot be used with a C(CITRIX-AG) monitor, because a CITRIX-AG monitor uses a secure + connection by default. + type: bool + + validatecred: + description: + - >- + Validate the credentials of the Xen Desktop DDC server user. Applicable to monitors of type + C(CITRIX-XD-DDC). + type: bool + + domain: + description: + - >- + Domain in which the XenDesktop Desktop Delivery Controller (DDC) servers or Web Interface servers are + present. Required by C(CITRIX-XD-DDC) and C(CITRIX-WI-EXTENDED) monitors for logging on to the DDC servers + and Web Interface servers, respectively. + + ipaddress: + description: + - >- + Set of IP addresses expected in the monitoring response from the DNS server, if the record type is A + or AAAA. Applicable to C(DNS) monitors. + - "Minimum length = 1" + + group: + description: + - >- + Name of a newsgroup available on the NNTP service that is to be monitored. The appliance periodically + generates an NNTP query for the name of the newsgroup and evaluates the response. If the newsgroup is + found on the server, the service is marked as UP. If the newsgroup does not exist or if the search + fails, the service is marked as DOWN. Applicable to NNTP monitors. + - "Minimum length = 1" + + filename: + description: + - >- + Name of a file on the FTP server. The appliance monitors the FTP service by periodically checking the + existence of the file on the server. Applicable to C(FTP-EXTENDED) monitors. + - "Minimum length = 1" + + basedn: + description: + - >- + The base distinguished name of the LDAP service, from where the LDAP server can begin the search for + the attributes in the monitoring query. Required for C(LDAP) service monitoring. + - "Minimum length = 1" + + binddn: + description: + - >- + The distinguished name with which an LDAP monitor can perform the Bind operation on the LDAP server. + Optional. Applicable to C(LDAP) monitors. + - "Minimum length = 1" + + filter: + description: + - "Filter criteria for the LDAP query. Optional." + - "Minimum length = 1" + + attribute: + description: + - >- + Attribute to evaluate when the LDAP server responds to the query. Success or failure of the + monitoring probe depends on whether the attribute exists in the response. Optional. + - "Minimum length = 1" + + database: + description: + - "Name of the database to connect to during authentication." + - "Minimum length = 1" + + oraclesid: + description: + - "Name of the service identifier that is used to connect to the Oracle database during authentication." + - "Minimum length = 1" + + sqlquery: + description: + - >- + SQL query for a C(MYSQL-ECV) or C(MSSQL-ECV) monitor. Sent to the database server after the server + authenticates the connection. + - "Minimum length = 1" + + evalrule: + description: + - >- + Default syntax expression that evaluates the database server's response to a MYSQL-ECV or MSSQL-ECV + monitoring query. Must produce a Boolean result. The result determines the state of the server. If + the expression returns TRUE, the probe succeeds. + - >- + For example, if you want the appliance to evaluate the error message to determine the state of the + server, use the rule C(MYSQL.RES.ROW(10) .TEXT_ELEM(2).EQ("MySQL")). + + mssqlprotocolversion: + choices: + - '70' + - '2000' + - '2000SP1' + - '2005' + - '2008' + - '2008R2' + - '2012' + - '2014' + description: + - "Version of MSSQL server that is to be monitored." + + Snmpoid: + description: + - "SNMP OID for C(SNMP) monitors." + - "Minimum length = 1" + + snmpcommunity: + description: + - "Community name for C(SNMP) monitors." + - "Minimum length = 1" + + snmpthreshold: + description: + - "Threshold for C(SNMP) monitors." + - "Minimum length = 1" + + snmpversion: + choices: + - 'V1' + - 'V2' + description: + - "SNMP version to be used for C(SNMP) monitors." + + metrictable: + description: + - "Metric table to which to bind metrics." + - "Minimum length = 1" + - "Maximum length = 99" + + application: + description: + - >- + Name of the application used to determine the state of the service. Applicable to monitors of type + C(CITRIX-XML-SERVICE). + - "Minimum length = 1" + + sitepath: + description: + - >- + URL of the logon page. For monitors of type C(CITRIX-WEB-INTERFACE), to monitor a dynamic page under the + site path, terminate the site path with a slash C(/). Applicable to C(CITRIX-WEB-INTERFACE), + C(CITRIX-WI-EXTENDED) and C(CITRIX-XDM) monitors. + - "Minimum length = 1" + + storename: + description: + - >- + Store Name. For monitors of type C(STOREFRONT), C(storename) is an optional argument defining storefront + service store name. Applicable to C(STOREFRONT) monitors. + - "Minimum length = 1" + + storefrontacctservice: + description: + - >- + Enable/Disable probing for Account Service. Applicable only to Store Front monitors. For + multi-tenancy configuration users my skip account service. + type: bool + + hostname: + description: + - "Hostname in the FQDN format (Example: C(porche.cars.org)). Applicable to C(STOREFRONT) monitors." + - "Minimum length = 1" + + netprofile: + description: + - "Name of the network profile." + - "Minimum length = 1" + - "Maximum length = 127" + + originhost: + description: + - >- + Origin-Host value for the Capabilities-Exchange-Request (CER) message to use for monitoring Diameter + servers. + - "Minimum length = 1" + + originrealm: + description: + - >- + Origin-Realm value for the Capabilities-Exchange-Request (CER) message to use for monitoring Diameter + servers. + - "Minimum length = 1" + + hostipaddress: + description: + - >- + Host-IP-Address value for the Capabilities-Exchange-Request (CER) message to use for monitoring + Diameter servers. If Host-IP-Address is not specified, the appliance inserts the mapped IP (MIP) + address or subnet IP (SNIP) address from which the CER request (the monitoring probe) is sent. + - "Minimum length = 1" + + vendorid: + description: + - >- + Vendor-Id value for the Capabilities-Exchange-Request (CER) message to use for monitoring Diameter + servers. + + productname: + description: + - >- + Product-Name value for the Capabilities-Exchange-Request (CER) message to use for monitoring Diameter + servers. + - "Minimum length = 1" + + firmwarerevision: + description: + - >- + Firmware-Revision value for the Capabilities-Exchange-Request (CER) message to use for monitoring + Diameter servers. + + authapplicationid: + description: + - >- + List of Auth-Application-Id attribute value pairs (AVPs) for the Capabilities-Exchange-Request (CER) + message to use for monitoring Diameter servers. A maximum of eight of these AVPs are supported in a + monitoring CER message. + - "Minimum value = C(0)" + - "Maximum value = C(4294967295)" + + acctapplicationid: + description: + - >- + List of Acct-Application-Id attribute value pairs (AVPs) for the Capabilities-Exchange-Request (CER) + message to use for monitoring Diameter servers. A maximum of eight of these AVPs are supported in a + monitoring message. + - "Minimum value = C(0)" + - "Maximum value = C(4294967295)" + + inbandsecurityid: + choices: + - 'NO_INBAND_SECURITY' + - 'TLS' + description: + - >- + Inband-Security-Id for the Capabilities-Exchange-Request (CER) message to use for monitoring Diameter + servers. + + supportedvendorids: + description: + - >- + List of Supported-Vendor-Id attribute value pairs (AVPs) for the Capabilities-Exchange-Request (CER) + message to use for monitoring Diameter servers. A maximum eight of these AVPs are supported in a + monitoring message. + - "Minimum value = C(1)" + - "Maximum value = C(4294967295)" + + vendorspecificvendorid: + description: + - >- + Vendor-Id to use in the Vendor-Specific-Application-Id grouped attribute-value pair (AVP) in the + monitoring CER message. To specify Auth-Application-Id or Acct-Application-Id in + Vendor-Specific-Application-Id, use vendorSpecificAuthApplicationIds or + vendorSpecificAcctApplicationIds, respectively. Only one Vendor-Id is supported for all the + Vendor-Specific-Application-Id AVPs in a CER monitoring message. + - "Minimum value = 1" + + vendorspecificauthapplicationids: + description: + - >- + List of Vendor-Specific-Auth-Application-Id attribute value pairs (AVPs) for the + Capabilities-Exchange-Request (CER) message to use for monitoring Diameter servers. A maximum of + eight of these AVPs are supported in a monitoring message. The specified value is combined with the + value of vendorSpecificVendorId to obtain the Vendor-Specific-Application-Id AVP in the CER + monitoring message. + - "Minimum value = C(0)" + - "Maximum value = C(4294967295)" + + vendorspecificacctapplicationids: + description: + - >- + List of Vendor-Specific-Acct-Application-Id attribute value pairs (AVPs) to use for monitoring + Diameter servers. A maximum of eight of these AVPs are supported in a monitoring message. The + specified value is combined with the value of vendorSpecificVendorId to obtain the + Vendor-Specific-Application-Id AVP in the CER monitoring message. + - "Minimum value = C(0)" + - "Maximum value = C(4294967295)" + + kcdaccount: + description: + - "KCD Account used by C(MSSQL) monitor." + - "Minimum length = 1" + - "Maximum length = 32" + + storedb: + choices: + - 'ENABLED' + - 'DISABLED' + description: + - >- + Store the database list populated with the responses to monitor probes. Used in database specific + load balancing if C(MSSQL-ECV)/C(MYSQL-ECV) monitor is configured. + + storefrontcheckbackendservices: + description: + - >- + This option will enable monitoring of services running on storefront server. Storefront services are + monitored by probing to a Windows service that runs on the Storefront server and exposes details of + which storefront services are running. + type: bool + + trofscode: + description: + - "Code expected when the server is under maintenance." + + trofsstring: + description: + - >- + String expected from the server for the service to be marked as trofs. Applicable to HTTP-ECV/TCP-ECV + monitors. + +extends_documentation_fragment: netscaler +requirements: + - nitro python sdk +''' + +EXAMPLES = ''' +- name: Set lb monitor + local_action: + nsip: 172.18.0.2 + nitro_user: nsroot + nitro_pass: nsroot + validate_certs: no + + + module: netscaler_lb_monitor + state: present + + monitorname: monitor_1 + type: HTTP-INLINE + action: DOWN + respcode: ['400'] +''' + +RETURN = ''' +loglines: + description: list of logged messages by the module + returned: always + type: list + sample: ['message 1', 'message 2'] + +msg: + description: Message detailing the failure reason + returned: failure + type: str + sample: "Action does not exist" + +diff: + description: List of differences between the actual configured object and the configuration specified in the module + returned: failure + type: dict + sample: { 'targetlbvserver': 'difference. ours: (str) server1 other: (str) server2' } +''' + +from ansible.module_utils.basic import AnsibleModule + +from ansible.module_utils.netscaler import ( + ConfigProxy, + get_nitro_client, + netscaler_common_arguments, + log, + loglines, + ensure_feature_is_enabled, + get_immutables_intersection +) + +try: + from nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbmonitor import lbmonitor + from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception + PYTHON_SDK_IMPORTED = True +except ImportError as e: + PYTHON_SDK_IMPORTED = False + + +def lbmonitor_exists(client, module): + log('Checking if monitor exists') + if lbmonitor.count_filtered(client, 'monitorname:%s' % module.params['monitorname']) > 0: + return True + else: + return False + + +def lbmonitor_identical(client, module, lbmonitor_proxy): + log('Checking if monitor is identical') + + count = lbmonitor.count_filtered(client, 'monitorname:%s' % module.params['monitorname']) + if count == 0: + return False + + lbmonitor_list = lbmonitor.get_filtered(client, 'monitorname:%s' % module.params['monitorname']) + diff_dict = lbmonitor_proxy.diff_object(lbmonitor_list[0]) + + # Skipping hashed fields since the cannot be compared directly + hashed_fields = [ + 'password', + 'secondarypassword', + 'radkey', + ] + for key in hashed_fields: + if key in diff_dict: + del diff_dict[key] + + if diff_dict == {}: + return True + else: + return False + + +def diff_list(client, module, lbmonitor_proxy): + monitor_list = lbmonitor.get_filtered(client, 'monitorname:%s' % module.params['monitorname']) + return lbmonitor_proxy.diff_object(monitor_list[0]) + + +def main(): + + module_specific_arguments = dict( + + monitorname=dict(type='str'), + + type=dict( + type='str', + choices=[ + 'PING', + 'TCP', + 'HTTP', + 'TCP-ECV', + 'HTTP-ECV', + 'UDP-ECV', + 'DNS', + 'FTP', + 'LDNS-PING', + 'LDNS-TCP', + 'LDNS-DNS', + 'RADIUS', + 'USER', + 'HTTP-INLINE', + 'SIP-UDP', + 'SIP-TCP', + 'LOAD', + 'FTP-EXTENDED', + 'SMTP', + 'SNMP', + 'NNTP', + 'MYSQL', + 'MYSQL-ECV', + 'MSSQL-ECV', + 'ORACLE-ECV', + 'LDAP', + 'POP3', + 'CITRIX-XML-SERVICE', + 'CITRIX-WEB-INTERFACE', + 'DNS-TCP', + 'RTSP', + 'ARP', + 'CITRIX-AG', + 'CITRIX-AAC-LOGINPAGE', + 'CITRIX-AAC-LAS', + 'CITRIX-XD-DDC', + 'ND6', + 'CITRIX-WI-EXTENDED', + 'DIAMETER', + 'RADIUS_ACCOUNTING', + 'STOREFRONT', + 'APPC', + 'SMPP', + 'CITRIX-XNC-ECV', + 'CITRIX-XDM', + 'CITRIX-STA-SERVICE', + 'CITRIX-STA-SERVICE-NHOP', + ] + ), + + action=dict( + type='str', + choices=[ + 'NONE', + 'LOG', + 'DOWN', + ] + ), + respcode=dict(type='list'), + httprequest=dict(type='str'), + rtsprequest=dict(type='str'), + customheaders=dict(type='str'), + maxforwards=dict(type='float'), + sipmethod=dict( + type='str', + choices=[ + 'OPTIONS', + 'INVITE', + 'REGISTER', + ] + ), + sipuri=dict(type='str'), + sipreguri=dict(type='str'), + send=dict(type='str'), + recv=dict(type='str'), + query=dict(type='str'), + querytype=dict( + type='str', + choices=[ + 'Address', + 'Zone', + 'AAAA', + ] + ), + scriptname=dict(type='str'), + scriptargs=dict(type='str'), + dispatcherip=dict(type='str'), + dispatcherport=dict(type='int'), + username=dict(type='str'), + password=dict(type='str'), + secondarypassword=dict(type='str'), + logonpointname=dict(type='str'), + lasversion=dict(type='str'), + radkey=dict(type='str'), + radnasid=dict(type='str'), + radnasip=dict(type='str'), + radaccounttype=dict(type='float'), + radframedip=dict(type='str'), + radapn=dict(type='str'), + radmsisdn=dict(type='str'), + radaccountsession=dict(type='str'), + lrtm=dict( + type='str', + choices=[ + 'ENABLED', + 'DISABLED', + ] + ), + deviation=dict(type='float'), + units1=dict( + type='str', + choices=[ + 'SEC', + 'MSEC', + 'MIN', + ] + ), + interval=dict(type='int'), + units3=dict( + type='str', + choices=[ + 'SEC', + 'MSEC', + 'MIN', + ] + ), + resptimeout=dict(type='int'), + units4=dict( + type='str', + choices=[ + 'SEC', + 'MSEC', + 'MIN', + ] + ), + resptimeoutthresh=dict(type='float'), + retries=dict(type='int'), + failureretries=dict(type='int'), + alertretries=dict(type='int'), + successretries=dict(type='int'), + downtime=dict(type='int'), + units2=dict( + type='str', + choices=[ + 'SEC', + 'MSEC', + 'MIN', + ] + ), + destip=dict(type='str'), + destport=dict(type='int'), + reverse=dict(type='bool'), + transparent=dict(type='bool'), + iptunnel=dict(type='bool'), + tos=dict(type='bool'), + tosid=dict(type='float'), + secure=dict(type='bool'), + validatecred=dict(type='bool'), + domain=dict(type='str'), + ipaddress=dict(type='list'), + group=dict(type='str'), + filename=dict(type='str'), + basedn=dict(type='str'), + binddn=dict(type='str'), + filter=dict(type='str'), + attribute=dict(type='str'), + database=dict(type='str'), + oraclesid=dict(type='str'), + sqlquery=dict(type='str'), + evalrule=dict(type='str'), + mssqlprotocolversion=dict( + type='str', + choices=[ + '70', + '2000', + '2000SP1', + '2005', + '2008', + '2008R2', + '2012', + '2014', + ] + ), + Snmpoid=dict(type='str'), + snmpcommunity=dict(type='str'), + snmpthreshold=dict(type='str'), + snmpversion=dict( + type='str', + choices=[ + 'V1', + 'V2', + ] + ), + application=dict(type='str'), + sitepath=dict(type='str'), + storename=dict(type='str'), + storefrontacctservice=dict(type='bool'), + hostname=dict(type='str'), + netprofile=dict(type='str'), + originhost=dict(type='str'), + originrealm=dict(type='str'), + hostipaddress=dict(type='str'), + vendorid=dict(type='float'), + productname=dict(type='str'), + firmwarerevision=dict(type='float'), + authapplicationid=dict(type='list'), + acctapplicationid=dict(type='list'), + inbandsecurityid=dict( + type='str', + choices=[ + 'NO_INBAND_SECURITY', + 'TLS', + ] + ), + supportedvendorids=dict(type='list'), + vendorspecificvendorid=dict(type='float'), + vendorspecificauthapplicationids=dict(type='list'), + vendorspecificacctapplicationids=dict(type='list'), + storedb=dict( + type='str', + choices=[ + 'ENABLED', + 'DISABLED', + ] + ), + storefrontcheckbackendservices=dict(type='bool'), + trofscode=dict(type='float'), + trofsstring=dict(type='str'), + ) + + hand_inserted_arguments = dict() + + argument_spec = dict() + argument_spec.update(module_specific_arguments) + argument_spec.update(netscaler_common_arguments) + argument_spec.update(hand_inserted_arguments) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + module_result = dict( + changed=False, + failed=False, + loglines=loglines, + ) + + # Fail the module if imports failed + if not PYTHON_SDK_IMPORTED: + module.fail_json(msg='Could not load nitro python sdk', **module_result) + + # Fallthrough to rest of execution + client = get_nitro_client(module) + + try: + client.login() + except nitro_exception as e: + msg = "nitro exception during login. errorcode=%s, message=%s" % (str(e.errorcode), e.message) + module.fail_json(msg=msg) + except Exception as e: + if str(type(e)) == "": + module.fail_json(msg='Connection error %s' % str(e)) + elif str(type(e)) == "": + module.fail_json(msg='SSL Error %s' % str(e)) + else: + module.fail_json(msg='Unexpected error during login %s' % str(e)) + + # Instantiate lb monitor object + readwrite_attrs = [ + 'monitorname', + 'type', + 'action', + 'respcode', + 'httprequest', + 'rtsprequest', + 'customheaders', + 'maxforwards', + 'sipmethod', + 'sipuri', + 'sipreguri', + 'send', + 'recv', + 'query', + 'querytype', + 'scriptname', + 'scriptargs', + 'dispatcherip', + 'dispatcherport', + 'username', + 'password', + 'secondarypassword', + 'logonpointname', + 'lasversion', + 'radkey', + 'radnasid', + 'radnasip', + 'radaccounttype', + 'radframedip', + 'radapn', + 'radmsisdn', + 'radaccountsession', + 'lrtm', + 'deviation', + 'units1', + 'interval', + 'units3', + 'resptimeout', + 'units4', + 'resptimeoutthresh', + 'retries', + 'failureretries', + 'alertretries', + 'successretries', + 'downtime', + 'units2', + 'destip', + 'destport', + 'reverse', + 'transparent', + 'iptunnel', + 'tos', + 'tosid', + 'secure', + 'validatecred', + 'domain', + 'ipaddress', + 'group', + 'filename', + 'basedn', + 'binddn', + 'filter', + 'attribute', + 'database', + 'oraclesid', + 'sqlquery', + 'evalrule', + 'mssqlprotocolversion', + 'Snmpoid', + 'snmpcommunity', + 'snmpthreshold', + 'snmpversion', + 'application', + 'sitepath', + 'storename', + 'storefrontacctservice', + 'netprofile', + 'originhost', + 'originrealm', + 'hostipaddress', + 'vendorid', + 'productname', + 'firmwarerevision', + 'authapplicationid', + 'acctapplicationid', + 'inbandsecurityid', + 'supportedvendorids', + 'vendorspecificvendorid', + 'vendorspecificauthapplicationids', + 'vendorspecificacctapplicationids', + 'storedb', + 'storefrontcheckbackendservices', + 'trofscode', + 'trofsstring', + ] + + readonly_attrs = [ + 'lrtmconf', + 'lrtmconfstr', + 'dynamicresponsetimeout', + 'dynamicinterval', + 'multimetrictable', + 'dup_state', + 'dup_weight', + 'weight', + ] + + immutable_attrs = [ + 'monitorname', + 'type', + 'units1', + 'units3', + 'units4', + 'units2', + 'Snmpoid', + 'hostname', + 'servicename', + 'servicegroupname', + ] + + transforms = { + 'storefrontcheckbackendservices': ['bool_yes_no'], + 'secure': ['bool_yes_no'], + 'tos': ['bool_yes_no'], + 'validatecred': ['bool_yes_no'], + 'storefrontacctservice': ['bool_yes_no'], + 'iptunnel': ['bool_yes_no'], + 'transparent': ['bool_yes_no'], + 'reverse': ['bool_yes_no'], + } + + lbmonitor_proxy = ConfigProxy( + actual=lbmonitor(), + client=client, + attribute_values_dict=module.params, + readwrite_attrs=readwrite_attrs, + readonly_attrs=readonly_attrs, + immutable_attrs=immutable_attrs, + transforms=transforms, + ) + + try: + ensure_feature_is_enabled(client, 'LB') + + if module.params['state'] == 'present': + log('Applying actions for state present') + if not lbmonitor_exists(client, module): + if not module.check_mode: + log('Adding monitor') + lbmonitor_proxy.add() + if module.params['save_config']: + client.save_config() + module_result['changed'] = True + elif not lbmonitor_identical(client, module, lbmonitor_proxy): + + # Check if we try to change value of immutable attributes + immutables_changed = get_immutables_intersection(lbmonitor_proxy, diff_list(client, module, lbmonitor_proxy).keys()) + if immutables_changed != []: + diff = diff_list(client, module, lbmonitor_proxy) + msg = 'Cannot update immutable attributes %s' % (immutables_changed,) + module.fail_json(msg=msg, diff=diff, **module_result) + + if not module.check_mode: + log('Updating monitor') + lbmonitor_proxy.update() + if module.params['save_config']: + client.save_config() + module_result['changed'] = True + else: + log('Doing nothing for monitor') + module_result['changed'] = False + + # Sanity check for result + log('Sanity checks for state present') + if not module.check_mode: + if not lbmonitor_exists(client, module): + module.fail_json(msg='lb monitor does not exist', **module_result) + if not lbmonitor_identical(client, module, lbmonitor_proxy): + module.fail_json( + msg='lb monitor is not configured correctly', + diff=diff_list(client, module, lbmonitor_proxy), + **module_result + ) + + elif module.params['state'] == 'absent': + log('Applying actions for state absent') + if lbmonitor_exists(client, module): + if not module.check_mode: + lbmonitor_proxy.delete() + if module.params['save_config']: + client.save_config() + module_result['changed'] = True + else: + module_result['changed'] = False + + # Sanity check for result + log('Sanity checks for state absent') + if not module.check_mode: + if lbmonitor_exists(client, module): + module.fail_json(msg='lb monitor still exists', **module_result) + + module_result['actual_attributes'] = lbmonitor_proxy.get_actual_rw_attributes(filter='monitorname') + except nitro_exception as e: + msg = "nitro exception errorcode=%s, message=%s" % (str(e.errorcode), e.message) + module.fail_json(msg=msg, **module_result) + + client.logout() + + module.exit_json(**module_result) + + +if __name__ == "__main__": + main() diff --git a/test/integration/roles/netscaler_lb_monitor/defaults/main.yaml b/test/integration/roles/netscaler_lb_monitor/defaults/main.yaml new file mode 100644 index 0000000000..641801f660 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/defaults/main.yaml @@ -0,0 +1,6 @@ +--- +testcase: "*" +test_cases: [] + +nitro_user: nsroot +nitro_pass: nsroot diff --git a/test/integration/roles/netscaler_lb_monitor/sample_inventory b/test/integration/roles/netscaler_lb_monitor/sample_inventory new file mode 100644 index 0000000000..4263579691 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/sample_inventory @@ -0,0 +1,5 @@ + + +[netscaler] + +netscaler01 nsip=172.18.0.2 nitro_user=nsroot nitro_pass=nsroot diff --git a/test/integration/roles/netscaler_lb_monitor/tasks/main.yaml b/test/integration/roles/netscaler_lb_monitor/tasks/main.yaml new file mode 100644 index 0000000000..84af8dca9e --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tasks/main.yaml @@ -0,0 +1,3 @@ +--- + +- { include: nitro.yaml, tags: ['nitro'] } diff --git a/test/integration/roles/netscaler_lb_monitor/tasks/nitro.yaml b/test/integration/roles/netscaler_lb_monitor/tasks/nitro.yaml new file mode 100644 index 0000000000..00ab502dda --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tasks/nitro.yaml @@ -0,0 +1,14 @@ +- name: collect all nitro test cases + find: + paths: "{{ role_path }}/tests/nitro" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac.yaml new file mode 100644 index 0000000000..416b766f6e --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_aac/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/remove.yaml new file mode 100644 index 0000000000..3ae75ff1f0 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-citrix-aac + type: CITRIX-AAC-LAS diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/setup.yaml new file mode 100644 index 0000000000..9ddf715149 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_aac/setup.yaml @@ -0,0 +1,17 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-citrix-aac + type: CITRIX-AAC-LAS + + lasversion: 7.1 + logonpointname: user diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag.yaml new file mode 100644 index 0000000000..837c21a491 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_ag/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/remove.yaml new file mode 100644 index 0000000000..3731d2f41b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-citrix-ag + type: CITRIX-AG diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/setup.yaml new file mode 100644 index 0000000000..5db6b51b55 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_ag/setup.yaml @@ -0,0 +1,18 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-citrix-ag + type: CITRIX-AG + + username: user1 + password: password1 + secondarypassword: password2 diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface.yaml new file mode 100644 index 0000000000..6c0cd6787b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml new file mode 100644 index 0000000000..92c4bb1d90 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-citrix-web-interface + type: CITRIX-WEB-INTERFACE diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml new file mode 100644 index 0000000000..66121efee4 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_web_interface/setup.yaml @@ -0,0 +1,16 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-citrix-web-interface + type: CITRIX-WEB-INTERFACE + + sitepath: hello/ diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc.yaml new file mode 100644 index 0000000000..53dece23a6 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml new file mode 100644 index 0000000000..2ee90e2331 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-citrix-xd-ddc + type: CITRIX-XD-DDC diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml new file mode 100644 index 0000000000..bedbc18d7a --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xd_doc/setup.yaml @@ -0,0 +1,17 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-citrix-xd-ddc + type: CITRIX-XD-DDC + + validatecred: no + domain: somedomain.com diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service.yaml new file mode 100644 index 0000000000..3fec67a0fa --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml new file mode 100644 index 0000000000..06c9a111ba --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-citrix-xml-service + type: CITRIX-XML-SERVICE diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml new file mode 100644 index 0000000000..b62ecf051a --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_citrix_xml_service/setup.yaml @@ -0,0 +1,17 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + + monitorname: lb-monitor-citrix-xml-service + type: CITRIX-XML-SERVICE + + application: app diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter.yaml new file mode 100644 index 0000000000..9e3690fbc0 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_diameter/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/remove.yaml new file mode 100644 index 0000000000..4268e599c5 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-diameter + type: DIAMETER diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/setup.yaml new file mode 100644 index 0000000000..90095e9871 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_diameter/setup.yaml @@ -0,0 +1,38 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-diameter + type: DIAMETER + + originhost: origin.host + originrealm: some.realm + hostipaddress: 192.168.1.1 + vendorid: 20 + productname: someproduct + firmwarerevision: 10 + authapplicationid: + - "100" + - "200" + inbandsecurityid: NO_INBAND_SECURITY + supportedvendorids: + - "10" + - "20" + vendorspecificvendorid: 10 + vendorspecificauthapplicationids: + - "11" + - "22" + vendorspecificacctapplicationids: + - "12" + - "23" + acctapplicationid: + - "1" + - "2" diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns.yaml new file mode 100644 index 0000000000..c0bb6a1dd1 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_dns/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/remove.yaml new file mode 100644 index 0000000000..778b5d5ff7 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-dns-tcp + type: DNS-TCP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/setup.yaml new file mode 100644 index 0000000000..49c27fd1a3 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_dns/setup.yaml @@ -0,0 +1,20 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-dns-tcp + type: DNS-TCP + + query: example.com + querytype: Address + ipaddress: + - 192.168.1.1 + - 192.168.1.2 diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp.yaml new file mode 100644 index 0000000000..e7f00b3a5b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ftp/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/remove.yaml new file mode 100644 index 0000000000..185ed15dd0 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-ftp + type: FTP-EXTENDED diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/setup.yaml new file mode 100644 index 0000000000..91df5c18d8 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ftp/setup.yaml @@ -0,0 +1,15 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-ftp + type: FTP-EXTENDED + filename: somefile.txt diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http.yaml new file mode 100644 index 0000000000..dd5859ae0d --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/remove.yaml new file mode 100644 index 0000000000..543e4ee587 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-http + type: HTTP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/setup.yaml new file mode 100644 index 0000000000..e09d193294 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http/setup.yaml @@ -0,0 +1,16 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-http + type: HTTP + + trofscode: 500 diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv.yaml new file mode 100644 index 0000000000..4393347b28 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_ecv/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/remove.yaml new file mode 100644 index 0000000000..c23a76fcbc --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-http-ecv + type: HTTP-ECV diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/setup.yaml new file mode 100644 index 0000000000..53e6d7fa28 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_ecv/setup.yaml @@ -0,0 +1,16 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-http-ecv + type: HTTP-ECV + + trofsstring: somestring diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline.yaml new file mode 100644 index 0000000000..9dd6f81190 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline.yaml @@ -0,0 +1,82 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/setup.yaml" + vars: + check_mode: no + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/update.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/update.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/update.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/update.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_http_inline/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/remove.yaml new file mode 100644 index 0000000000..ecff6af642 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/remove.yaml @@ -0,0 +1,13 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + monitorname: lb-monitor-1 + type: HTTP-INLINE diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/setup.yaml new file mode 100644 index 0000000000..35993972ff --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/setup.yaml @@ -0,0 +1,20 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-1 + type: HTTP-INLINE + action: DOWN + respcode: [ "200", "203"] + httprequest: "HEAD /file.html" + + + customheaders: "HEADER_CUSTOM: NONE\r\n" diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/update.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/update.yaml new file mode 100644 index 0000000000..8a5095641d --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_http_inline/update.yaml @@ -0,0 +1,20 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-1 + type: HTTP-INLINE + action: DOWN + respcode: [ "200-201"] + httprequest: "HEAD /new_file.html" + + + customheaders: "HEADER_CUSTOM: NONE\r\n" diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap.yaml new file mode 100644 index 0000000000..38b799528a --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_ldap/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/remove.yaml new file mode 100644 index 0000000000..4ae839f6d2 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-ldap + type: LDAP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/setup.yaml new file mode 100644 index 0000000000..25f376ccb1 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_ldap/setup.yaml @@ -0,0 +1,19 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-ldap + type: LDAP + + basedn: example.com + binddn: example.com + filter: somefilter + attribute: cn diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load.yaml new file mode 100644 index 0000000000..0aea839c60 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_load/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/remove.yaml new file mode 100644 index 0000000000..ee1cc6a4c0 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-load + type: LOAD diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/setup.yaml new file mode 100644 index 0000000000..41d38f134b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_load/setup.yaml @@ -0,0 +1,16 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-load + type: LOAD + + snmpversion: V1 diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp.yaml new file mode 100644 index 0000000000..0b6e31e64f --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_nntp/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/remove.yaml new file mode 100644 index 0000000000..179eb697c7 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-nntp + type: NNTP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/setup.yaml new file mode 100644 index 0000000000..b0740b5d6e --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_nntp/setup.yaml @@ -0,0 +1,16 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-nntp + type: NNTP + + group: somegroup.nntp diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius.yaml new file mode 100644 index 0000000000..a8a0ed5f2f --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/remove.yaml new file mode 100644 index 0000000000..6b893e9baf --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-radius + type: RADIUS diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/setup.yaml new file mode 100644 index 0000000000..5c269ed27d --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius/setup.yaml @@ -0,0 +1,20 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-radius + type: RADIUS + + username: someuser + password: somepass + radkey: somekey + radnasid: someid + radnasip: 192.168.1.1 diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting.yaml new file mode 100644 index 0000000000..fd108d0d11 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_radius_accounting/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/remove.yaml new file mode 100644 index 0000000000..ac8a40216b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-radius-accounting + type: RADIUS_ACCOUNTING diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/setup.yaml new file mode 100644 index 0000000000..6d3ff50b46 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_radius_accounting/setup.yaml @@ -0,0 +1,24 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-radius-accounting + type: RADIUS_ACCOUNTING + + username: someuser + password: somepass + radkey: somekey + + radaccounttype: 10 + radframedip: 192.168.1.1 + radapn: someapn + radmsisdn: someisdn + radaccountsession: sessionid diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp.yaml new file mode 100644 index 0000000000..798203619b --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_rtsp/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/remove.yaml new file mode 100644 index 0000000000..8d78f628b4 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/remove.yaml @@ -0,0 +1,13 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + monitorname: lb-monitor-rtsp + type: RTSP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/setup.yaml new file mode 100644 index 0000000000..b84a881775 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_rtsp/setup.yaml @@ -0,0 +1,38 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-rtsp + type: RTSP + + rtsprequest: OPTIONS + + deviation: 100 + units1: MSEC + interval: 5 + units3: SEC + resptimeout: 10 + units4: MSEC + resptimeoutthresh: 10 + retries: 5 + failureretries: 3 + alertretries: 2 + successretries: 4 + downtime: 60 + units2: MSEC + destip: 10.10.10.10 + destport: 1111 + reverse: yes + transparent: yes + iptunnel: no + tos: yes + tosid: 20 + secure: no diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip.yaml new file mode 100644 index 0000000000..8334d144a1 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_sip/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/remove.yaml new file mode 100644 index 0000000000..dcc1b3a948 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/remove.yaml @@ -0,0 +1,13 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + monitorname: lb-monitor-2 + type: SIP-UDP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/setup.yaml new file mode 100644 index 0000000000..661c3d7883 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_sip/setup.yaml @@ -0,0 +1,22 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-2 + type: SIP-UDP + customheaders: "HEADER_CUSTOM: NONE\r\n" + + maxforwards: 5 + sipmethod: REGISTER + sipuri: sip:sip.test + sipreguri: sip:sip.register + + lrtm: DISABLED diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp.yaml new file mode 100644 index 0000000000..356baf2b69 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_snmp/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/remove.yaml new file mode 100644 index 0000000000..c87c5e0a2a --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-snmp + type: SNMP diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/setup.yaml new file mode 100644 index 0000000000..143d7054a2 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_snmp/setup.yaml @@ -0,0 +1,18 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-snmp + type: SNMP + + Snmpoid: some.id + snmpcommunity: some.community + snmpthreshold: threshold diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront.yaml new file mode 100644 index 0000000000..6872d0ee57 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_storefront/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/remove.yaml new file mode 100644 index 0000000000..ccfd6ec0f9 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-storefront + type: STOREFRONT diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/setup.yaml new file mode 100644 index 0000000000..28cd872c4c --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_storefront/setup.yaml @@ -0,0 +1,18 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-storefront + type: STOREFRONT + + storename: store + storefrontacctservice: yes + storefrontcheckbackendservices: yes diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp.yaml new file mode 100644 index 0000000000..996774ef06 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_tcp/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/remove.yaml new file mode 100644 index 0000000000..9e36ca532e --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/remove.yaml @@ -0,0 +1,13 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + monitorname: lb-monitor-tcp-ecv + type: TCP-ECV diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/setup.yaml new file mode 100644 index 0000000000..d2ead562a4 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_tcp/setup.yaml @@ -0,0 +1,17 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-tcp-ecv + type: TCP-ECV + + send: sendstring + recv: recvstring diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user.yaml new file mode 100644 index 0000000000..5eebdd67ea --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user.yaml @@ -0,0 +1,57 @@ +--- + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/setup.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/setup.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/setup.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/setup.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/remove.yaml" + vars: + check_mode: yes + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/remove.yaml" + vars: + check_mode: no + +- assert: + that: result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/remove.yaml" + vars: + check_mode: yes + +- assert: + that: not result|changed + +- include: "{{ role_path }}/tests/nitro/lb_monitor_user/remove.yaml" + vars: + check_mode: no + +- assert: + that: not result|changed diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/remove.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/remove.yaml new file mode 100644 index 0000000000..dce9d4d950 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/remove.yaml @@ -0,0 +1,14 @@ +--- + +- name: remove lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: absent + + monitorname: lb-monitor-user + type: USER diff --git a/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/setup.yaml b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/setup.yaml new file mode 100644 index 0000000000..f95f78d777 --- /dev/null +++ b/test/integration/roles/netscaler_lb_monitor/tests/nitro/lb_monitor_user/setup.yaml @@ -0,0 +1,19 @@ +--- + +- name: setup lb monitor + register: result + check_mode: "{{ check_mode }}" + delegate_to: localhost + netscaler_lb_monitor: + nitro_user: "{{nitro_user}}" + nitro_pass: "{{nitro_pass}}" + nsip: "{{nsip}}" + state: present + + monitorname: lb-monitor-user + type: USER + + scriptname: myscript.sh + scriptargs: argument1 argument2 + dispatcherip: 10.10.10.10 + dispatcherport: 22 diff --git a/test/units/modules/network/netscaler/test_netscaler_lb_monitor.py b/test/units/modules/network/netscaler/test_netscaler_lb_monitor.py new file mode 100644 index 0000000000..d45ffdf7cc --- /dev/null +++ b/test/units/modules/network/netscaler/test_netscaler_lb_monitor.py @@ -0,0 +1,513 @@ + +# Copyright (c) 2017 Citrix Systems +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +from ansible.compat.tests.mock import patch, Mock, MagicMock, call +from .netscaler_module import TestModule, nitro_base_patcher, set_module_args + +import sys + +if sys.version_info[:2] != (2, 6): + import requests + + +class TestNetscalerLBVServerModule(TestModule): + + @classmethod + def setUpClass(cls): + class MockException(Exception): + pass + + cls.MockException = MockException + + m = MagicMock() + nssrc_modules_mock = { + 'nssrc.com.citrix.netscaler.nitro.resource.config.lb': m, + 'nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbmonitor': m, + 'nssrc.com.citrix.netscaler.nitro.resource.config.lb.lbmonitor.lbvmonitor': m, + } + + cls.nitro_specific_patcher = patch.dict(sys.modules, nssrc_modules_mock) + cls.nitro_base_patcher = nitro_base_patcher + + @classmethod + def tearDownClass(cls): + cls.nitro_base_patcher.stop() + cls.nitro_specific_patcher.stop() + + def setUp(self): + self.nitro_base_patcher.start() + self.nitro_specific_patcher.start() + + # Setup minimal required arguments to pass AnsibleModule argument parsing + + def tearDown(self): + self.nitro_base_patcher.stop() + self.nitro_specific_patcher.stop() + + def test_graceful_nitro_api_import_error(self): + # Stop nitro api patching to cause ImportError + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + self.nitro_base_patcher.stop() + self.nitro_specific_patcher.stop() + from ansible.modules.network.netscaler import netscaler_lb_monitor + self.module = netscaler_lb_monitor + result = self.failed() + self.assertEqual(result['msg'], 'Could not load nitro python sdk') + + def test_graceful_nitro_error_on_login(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + class MockException(Exception): + def __init__(self, *args, **kwargs): + self.errorcode = 0 + self.message = '' + + client_mock = Mock() + client_mock.login = Mock(side_effect=MockException) + m = Mock(return_value=client_mock) + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + nitro_exception=MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertTrue(result['msg'].startswith('nitro exception'), msg='nitro exception during login not handled properly') + + def test_graceful_no_connection_error(self): + + if sys.version_info[:2] == (2, 6): + self.skipTest('requests library not available under python2.6') + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + attrs = {'login.side_effect': requests.exceptions.ConnectionError} + client_mock.configure_mock(**attrs) + m = Mock(return_value=client_mock) + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + nitro_exception=self.MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertTrue(result['msg'].startswith('Connection error'), msg='Connection error was not handled gracefully') + + def test_graceful_login_error(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + if sys.version_info[:2] == (2, 6): + self.skipTest('requests library not available under python2.6') + + client_mock = Mock() + attrs = {'login.side_effect': requests.exceptions.SSLError} + client_mock.configure_mock(**attrs) + m = Mock(return_value=client_mock) + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + nitro_exception=self.MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertTrue(result['msg'].startswith('SSL Error'), msg='SSL Error was not handled gracefully') + + def test_save_config_called_on_state_present(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + m = Mock(return_value=client_mock) + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + lbmonitor_exists=Mock(side_effect=[False, True]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + ): + self.module = netscaler_lb_monitor + self.exited() + self.assertIn(call.save_config(), client_mock.mock_calls) + + def test_save_config_called_on_state_absent(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='absent', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + m = Mock(return_value=client_mock) + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + lbmonitor_exists=Mock(side_effect=[True, False]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + ): + self.module = netscaler_lb_monitor + self.exited() + self.assertIn(call.save_config(), client_mock.mock_calls) + + def test_save_config_not_called_on_state_present(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + m = Mock(return_value=client_mock) + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + lbmonitor_exists=Mock(side_effect=[False, True]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + ): + self.module = netscaler_lb_monitor + self.exited() + self.assertNotIn(call.save_config(), client_mock.mock_calls) + + def test_save_config_not_called_on_state_absent(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='absent', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + m = Mock(return_value=client_mock) + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=m, + lbmonitor_exists=Mock(side_effect=[True, False]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + ): + self.module = netscaler_lb_monitor + self.exited() + self.assertNotIn(call.save_config(), client_mock.mock_calls) + + def test_ensure_feature_is_enabled_called(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + feature_mock = Mock() + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + lbmonitor_exists=Mock(side_effect=[True, True]), + lbmonitor_identical=Mock(side_effect=[True, True]), + + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=feature_mock, + ): + self.module = netscaler_lb_monitor + self.exited() + feature_mock.assert_called_with(client_mock, 'LB') + + def test_ensure_feature_is_enabled_nitro_exception_caught(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + client_mock = Mock() + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + errorcode = 10 + message = 'mock error' + + class MockException(Exception): + def __init__(self): + self.errorcode = errorcode + self.message = message + + feature_mock = Mock(side_effect=MockException) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + lbmonitor_exists=Mock(side_effect=[True, True]), + lbmonitor_identical=Mock(side_effect=[True, True]), + + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=feature_mock, + nitro_exception=MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + expected_msg = 'nitro exception errorcode=%s, message=%s' % (errorcode, message) + self.assertEqual(result['msg'], expected_msg, 'Failed to handle nitro exception') + + def test_create_new_lb_monitor_workflow(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=Mock()), + lbmonitor_exists=Mock(side_effect=[False, True]), + lbmonitor_identical=Mock(side_effect=[True]), + + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + ): + self.module = netscaler_lb_monitor + result = self.exited() + lb_monitor_proxy_mock.assert_has_calls([call.add()]) + self.assertTrue(result['changed']) + + def test_update_lb_monitor_workflow(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + save_config=False, + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=Mock()), + lbmonitor_exists=Mock(side_effect=[True, True]), + lbmonitor_identical=Mock(side_effect=[False, True]), + + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + get_immutables_intersection=Mock(return_value=[]), + diff_list=Mock(return_value={}), + ): + self.module = netscaler_lb_monitor + result = self.exited() + lb_monitor_proxy_mock.assert_has_calls([call.update()]) + self.assertTrue(result['changed']) + + def test_lb_monitor_exists_sanity_check(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + client_mock = Mock() + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + lbmonitor_exists=Mock(side_effect=[False, False]), + lbmonitor_identical=Mock(side_effect=[False, True]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + nitro_exception=self.MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertEqual(result['msg'], 'lb monitor does not exist') + + def test_lb_monitor_identical_sanity_check(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + client_mock = Mock() + + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + lbmonitor_exists=Mock(side_effect=[True, True]), + lbmonitor_identical=Mock(side_effect=[False, False]), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + get_immutables_intersection=(Mock(return_value=[])), + nitro_exception=self.MockException, + diff_list=Mock(return_value={}), + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertEqual(result['msg'], 'lb monitor is not configured correctly') + + def test_absent_state_workflow(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='absent', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + client_mock = Mock() + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + lbmonitor_exists=Mock(side_effect=[True, False]), + ): + self.module = netscaler_lb_monitor + result = self.exited() + lb_monitor_proxy_mock.assert_has_calls([call.delete()]) + self.assertTrue(result['changed']) + + def test_absent_state_sanity_check(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='absent', + )) + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + client_mock = Mock() + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(return_value=True), + lbmonitor_exists=Mock(side_effect=[True, True]), + nitro_exception=self.MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + lb_monitor_proxy_mock.assert_has_calls([call.delete()]) + self.assertEqual(result['msg'], 'lb monitor still exists') + + def test_get_immutables_failure(self): + set_module_args(dict( + nitro_user='user', + nitro_pass='pass', + nsip='1.1.1.1', + state='present', + )) + + from ansible.modules.network.netscaler import netscaler_lb_monitor + + lb_monitor_proxy_mock = Mock(diff_object=Mock(return_value={})) + + client_mock = Mock() + m = Mock(return_value=['some']) + with patch.multiple( + 'ansible.modules.network.netscaler.netscaler_lb_monitor', + get_nitro_client=Mock(return_value=client_mock), + ConfigProxy=Mock(return_value=lb_monitor_proxy_mock), + ensure_feature_is_enabled=Mock(), + lbmonitor_exists=Mock(side_effect=[True, True]), + lbmonitor_identical=Mock(side_effect=[False, True]), + get_immutables_intersection=m, + diff_list=Mock(return_value={}), + nitro_exception=self.MockException, + ): + self.module = netscaler_lb_monitor + result = self.failed() + self.assertTrue( + result['msg'].startswith('Cannot update immutable attributes'), + msg='Did not handle immutables error correctly', + )