From 7ba7e3bd698fb4204ff5202aff3f4e4f8801e19d Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 15 Jan 2015 11:38:20 -0600 Subject: [PATCH] Add tests for rax_clb --- test/integration/cleanup_rax.py | 29 +- test/integration/rackspace.yml | 3 + .../roles/test_rax_clb/defaults/main.yml | 3 + .../roles/test_rax_clb/tasks/main.yml | 851 ++++++++++++++++++ 4 files changed, 885 insertions(+), 1 deletion(-) create mode 100644 test/integration/roles/test_rax_clb/defaults/main.yml create mode 100644 test/integration/roles/test_rax_clb/tasks/main.yml diff --git a/test/integration/cleanup_rax.py b/test/integration/cleanup_rax.py index 5fdd15d8a1d..f396bbdb68d 100644 --- a/test/integration/cleanup_rax.py +++ b/test/integration/cleanup_rax.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os +import re import yaml import argparse @@ -11,6 +12,19 @@ except ImportError: HAS_PYRAX = False +def rax_list_iterator(svc, *args, **kwargs): + method = kwargs.pop('method', 'list') + items = getattr(svc, method)(*args, **kwargs) + while items: + retrieved = getattr(svc, method)(*args, marker=items[-1].id, **kwargs) + if items and retrieved and items[-1].id == retrieved[0].id: + del items[-1] + items.extend(retrieved) + if len(retrieved) < 2: + break + return items + + def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-y', '--yes', action='store_true', dest='assumeyes', @@ -53,15 +67,27 @@ def prompt_and_delete(item, prompt, assumeyes): def delete_rax(args): """Function for deleting CloudServers""" + search_opts = dict(name='^%s' % args.match_re) for region in pyrax.identity.services.compute.regions: cs = pyrax.connect_to_cloudservers(region=region) - servers = cs.servers.list(search_opts=dict(name='^%s' % args.match_re)) + servers = rax_list_iterator(cs.servers, search_opts=search_opts) for server in servers: prompt_and_delete(server, 'Delete matching %s? [y/n]: ' % server, args.assumeyes) +def delete_rax_clb(args): + """Function for deleting Cloud Load Balancers""" + for region in pyrax.identity.services.load_balancer.regions: + clb = pyrax.connect_to_cloud_loadbalancers(region=region) + for lb in rax_list_iterator(clb): + if re.search(args.match_re, lb.name): + prompt_and_delete(lb, + 'Delete matching %s? [y/n]: ' % lb, + args.assumeyes) + + def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') @@ -69,6 +95,7 @@ def main(): args = parse_args() authenticate() delete_rax(args) + delete_rax_clb(args) if __name__ == '__main__': diff --git a/test/integration/rackspace.yml b/test/integration/rackspace.yml index fd3079e9de0..7d6d86c4cff 100644 --- a/test/integration/rackspace.yml +++ b/test/integration/rackspace.yml @@ -7,3 +7,6 @@ roles: - role: test_rax tags: test_rax + + - role: test_rax_clb + tags: test_rax_clb diff --git a/test/integration/roles/test_rax_clb/defaults/main.yml b/test/integration/roles/test_rax_clb/defaults/main.yml new file mode 100644 index 00000000000..4854b645cf5 --- /dev/null +++ b/test/integration/roles/test_rax_clb/defaults/main.yml @@ -0,0 +1,3 @@ +--- +rackspace_region: IAD +resource_prefix: ansible-testing diff --git a/test/integration/roles/test_rax_clb/tasks/main.yml b/test/integration/roles/test_rax_clb/tasks/main.yml new file mode 100644 index 00000000000..9cc282e5eb0 --- /dev/null +++ b/test/integration/roles/test_rax_clb/tasks/main.yml @@ -0,0 +1,851 @@ +--- +- name: Check for required variables + assert: + that: + - resource_prefix is defined and resource_prefix + - rackspace_username is defined and rackspace_username + - rackspace_api_key is defined and rackspace_api_key + - rackspace_region is defined and rackspace_region + +# ============================================================ +- name: Test rax_clb with no args + rax_clb: + ignore_errors: true + register: rax_clb + +- name: Validate results of rax_clb with no args + assert: + that: + - rax_clb|failed + - rax_clb.msg == 'No credentials supplied!' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with credentials + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + ignore_errors: true + register: rax_clb + +- name: Validate results of rax_clb with only creds + assert: + that: + - rax_clb|failed + - rax_clb.msg.startswith('None is not a valid region') +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds and region + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + ignore_errors: true + register: rax_clb + +## This assertion is currently failing, due to the module not providing the correct name of the missing argument +- name: Validate rax_clb creds and region + assert: + that: + - rax_clb|failed + - rax_clb.msg == 'name is required for rax_clb' + ignore_errors: true +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region and name + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region and name + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 80 + - rax_clb.balancer.protocol == 'HTTP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'LEAST_CONNECTIONS' + +- name: "Delete integration 1" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-1" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 1" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-1" + +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name and protocol + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + protocol: TCP + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name and protocol + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 80 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 2" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-2" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 2" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-2" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol and port + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + protocol: TCP + port: 8080 + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol and port + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 3" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-3" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 3" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-3" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port and type + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + protocol: TCP + port: 8080 + type: SERVICENET + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol and type + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 30 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 4" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-4" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 4" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-4" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid timeout + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - rax_clb.msg == '"timeout" must be greater than or equal to 30' +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type and timeout + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type and timeout + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + +- name: "Delete integration 5" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-5" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 5" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-5" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type, timeout and algorithm + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + algorithm: RANDOM + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type, timeout and algorithm + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.metadata is not defined + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'RANDOM' + +- name: "Delete integration 6" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-6" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 6" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-6" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid type + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + type: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of type must be one of: PUBLIC,SERVICENET, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid protocol + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + protocol: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of protocol must be one of: DNS_TCP,DNS_UDP,FTP,HTTP,HTTPS,IMAPS,IMAPv4,LDAP,LDAPS,MYSQL,POP3,POP3S,SMTP,TCP,TCP_CLIENT_FIRST,UDP,UDP_STREAM,SFTP, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid algorithm + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-fail" + algorithm: BAD + timeout: 1 + wait: true + ignore_errors: true + register: rax_clb + +- name: Validate rax_clb with invalid timeout + assert: + that: + - rax_clb|failed + - "rax_clb.msg == 'value of algorithm must be one of: RANDOM,LEAST_CONNECTIONS,ROUND_ROBIN,WEIGHTED_LEAST_CONNECTIONS,WEIGHTED_ROUND_ROBIN, got: BAD'" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with creds, region, name, protocol, port, type, timeout, algorithm and metadata + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-7" + protocol: TCP + port: 8080 + type: SERVICENET + timeout: 60 + algorithm: RANDOM + meta: + foo: bar + wait: true + register: rax_clb + +- name: Validate rax_clb with creds, region, name, protocol, type, timeout, algorithm and metadata + assert: + that: + - rax_clb|success + - rax_clb.balancer.port == 8080 + - rax_clb.balancer.protocol == 'TCP' + - rax_clb.balancer.timeout == 60 + - rax_clb.balancer.virtual_ips.0.type == 'SERVICENET' + - rax_clb.balancer.status == 'ACTIVE' + - rax_clb.balancer.algorithm == 'RANDOM' + - rax_clb.balancer.metadata.0.key == 'foo' + - rax_clb.balancer.metadata.0.value == 'bar' + +- name: "Delete integration 7" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-7" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 7" + assert: + that: + - rax_clb|changed + - rax_clb.balancer.name == "{{ resource_prefix }}-7" +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with shared VIP HTTP + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTP" + wait: true + register: rax_clb_http + +- name: Validate rax_clb with shared VIP HTTP + assert: + that: + - rax_clb_http|success + - rax_clb_http.balancer.protocol == 'HTTP' + - rax_clb_http.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb_http.balancer.status == 'ACTIVE' + +- name: Test rax_clb with shared VIP HTTPS + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTPS" + protocol: HTTPS + port: 443 + wait: true + vip_id: "{{ (rax_clb_http.balancer.virtual_ips|first).id }}" + register: rax_clb_https + +- name: Validate Test rax_clb with shared VIP + assert: + that: + - rax_clb_https|success + - rax_clb_https.balancer.protocol == 'HTTPS' + - rax_clb_https.balancer.status == 'ACTIVE' + - rax_clb_http.balancer.virtual_ips == rax_clb_https.balancer.virtual_ips + +- name: "Delete integration 8 HTTP" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTP" + state: absent + wait: true + register: rax_clb_http + +- name: "Delete integration 8 HTTPS" + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-8-HTTPS" + state: absent + wait: true + register: rax_clb_http + +- name: "Validate delete integration 8" + assert: + that: + - rax_clb_http|changed + - rax_clb_https|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated protocol 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + wait: true + register: rax_clb_p1 + +- name: Validate rax_clb with updated protocol 1 + assert: + that: + - rax_clb_p1|success + - rax_clb_p1.balancer.protocol == 'HTTP' + - rax_clb_p1.balancer.virtual_ips.0.type == 'PUBLIC' + - rax_clb_p1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated protocol 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + protocol: TCP + wait: true + register: rax_clb_p2 + +- name: Validate rax_clb with updated protocol 2 + assert: + that: + - rax_clb_p1.balancer.id == rax_clb_p2.balancer.id + - rax_clb_p2|success + - rax_clb_p2|changed + - rax_clb_p2.balancer.protocol == 'TCP' + - rax_clb_p2.balancer.status == 'ACTIVE' + +- name: Delete integration 9 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-9" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 9" + assert: + that: + - rax_clb|changed +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated algorithm 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + wait: true + register: rax_clb_a1 + +- name: Validate rax_clb with updated algorithm 1 + assert: + that: + - rax_clb_a1|success + - rax_clb_a1.balancer.algorithm == 'LEAST_CONNECTIONS' + - rax_clb_a1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated algoritm 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + algorithm: RANDOM + wait: true + register: rax_clb_a2 + +- name: Validate rax_clb with updated algorithm 2 + assert: + that: + - rax_clb_a1.balancer.id == rax_clb_a2.balancer.id + - rax_clb_a2|success + - rax_clb_a2|changed + - rax_clb_a2.balancer.algorithm == 'RANDOM' + - rax_clb_a2.balancer.status == 'ACTIVE' + +- name: Delete integration 10 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-10" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 10" + assert: + that: + - rax_clb|changed + - rax_clb_a1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated port 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated port 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.port == 80 + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated port 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + port: 8080 + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated port 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.port == 8080 + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 11 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-11" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 11" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated timeout 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated timeout 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.timeout == 30 + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with updated timeout 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + timeout: 60 + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated timeout 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.timeout == 60 + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 12 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-12" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 12" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with invalid updated type 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with invalid updated type 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.status == 'ACTIVE' + +- name: Test rax_clb with invalid updated type 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + type: SERVICENET + wait: true + register: rax_clb_2 + ignore_errors: true + +- name: Validate rax_clb with updated timeout 2 + assert: + that: + - rax_clb_2|failed + - rax_clb_2.msg == 'Load balancer Virtual IP type cannot be changed' + +- name: Delete integration 13 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-13" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 13" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================ + + + +# ============================================================ +- name: Test rax_clb with updated meta 1 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + wait: true + register: rax_clb_1 + +- name: Validate rax_clb with updated meta 1 + assert: + that: + - rax_clb_1|success + - rax_clb_1.balancer.status == 'ACTIVE' + - rax_clb_1.balancer.metadata is not defined + +- name: Test rax_clb with updated meta 2 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + meta: + foo: bar + wait: true + register: rax_clb_2 + +- name: Validate rax_clb with updated meta 2 + assert: + that: + - rax_clb_1.balancer.id == rax_clb_2.balancer.id + - rax_clb_2|success + - rax_clb_2|changed + - rax_clb_2.balancer.metadata.0.key == 'foo' + - rax_clb_2.balancer.metadata.0.value == 'bar' + - rax_clb_2.balancer.status == 'ACTIVE' + +- name: Delete integration 14 + rax_clb: + username: "{{ rackspace_username }}" + api_key: "{{ rackspace_api_key }}" + region: "{{ rackspace_region }}" + name: "{{ resource_prefix }}-14" + state: absent + wait: true + register: rax_clb + +- name: "Validate delete integration 14" + assert: + that: + - rax_clb|changed + - rax_clb_1.balancer.id == rax_clb.balancer.id +# ============================================================