ansible/test/integration/roles/test_rax_clb/tasks/main.yml

858 lines
23 KiB
YAML
Raw Normal View History

2015-01-15 18:38:20 +01:00
# ============================================================
- 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 == 'missing required arguments: name'
# ============================================================
# ============================================================
- name: Test rax_clb with name
rax_clb:
name: fail
ignore_errors: true
register: rax_clb
- name: Validate results of rax_clb with only creds
2015-01-15 18:38:20 +01:00
assert:
that:
- rax_clb|failed
- rax_clb.msg == 'No credentials supplied!'
# ============================================================
# ============================================================
- name: Test rax_clb with name and credentials
2015-01-15 18:38:20 +01:00
rax_clb:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
name: fail
2015-01-15 18:38:20 +01:00
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
- name: Validate rax_clb creds and region
assert:
that:
- rax_clb|failed
- rax_clb.msg == 'missing required arguments: name'
2015-01-15 18:38:20 +01:00
# ============================================================
# ============================================================
- 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'
2015-04-28 15:36:42 +02:00
- name: Test rax_clb with updated algorithm 2
2015-01-15 18:38:20 +01:00
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
# ============================================================