You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/legacy/roles/test_rax/tasks/main.yml

870 lines
24 KiB
YAML

# ============================================================
- name: Test rax with no args
rax:
ignore_errors: true
register: rax
- name: Validate results of rax with no args
assert:
that:
- rax is failed
- rax.msg == 'No credentials supplied!'
# ============================================================
# ============================================================
- name: Test rax with credentials
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
ignore_errors: true
register: rax
- name: Validate results of rax with only creds
assert:
that:
- rax is failed
- rax.msg.startswith('None is not a valid region')
# ============================================================
# ============================================================
- name: Test rax with creds and region
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
ignore_errors: true
register: rax
- name: Validate rax creds and region
assert:
that:
- rax is failed
- rax.msg == 'image is required for the "rax" module'
# ============================================================
# ============================================================
- name: Test rax with creds, region and image
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
ignore_errors: true
register: rax
- name: Validate rax with creds, region and image
assert:
that:
- rax is failed
- rax.msg == 'flavor is required for the "rax" module'
# ============================================================
# ============================================================
- name: Test rax with creds, region, image and flavor
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
ignore_errors: true
register: rax
- name: Validate rax with creds, region, image and flavor
assert:
that:
- rax is failed
- rax.msg == 'name is required for the "rax" module'
# ============================================================
# ============================================================
- name: Test rax with creds, region, image, flavor and name
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-1"
register: rax
- name: Validate rax with creds, region, image, flavor and name
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-1"
- rax.instances[0] == rax.success[0]
- rax.instances[0].rax_status == 'BUILD'
- name: "Delete integration 1"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-1"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 1"
assert:
that:
- rax is changed
- rax.action == 'delete'
- rax.success[0].name == "{{ resource_prefix }}-1"
# ============================================================
# ============================================================
- name: Test rax basic idempotency 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-2"
- rax.instances[0] == rax.success[0]
- rax.instances[0].rax_status == 'ACTIVE'
- name: Test rax basic idempotency 2
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency 2
assert:
that:
- rax is successful
- rax is not changed
- not rax.action
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-2"
- not rax.success
- name: "Delete integration 2"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-2"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 2"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success[0].name == "{{ resource_prefix }}-2"
- rax.success[0].rax_status == "DELETED"
# ============================================================
# ============================================================
- name: Test rax basic idempotency with meta 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-3"
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency with meta 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-3"
- rax.instances[0] == rax.success[0]
- rax.instances[0].rax_status == 'ACTIVE'
- rax.instances[0].rax_metadata.foo == 'bar'
- name: Test rax basic idempotency with meta 2
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-3"
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency with meta 2
assert:
that:
- rax is successful
- rax is not changed
- not rax.action
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-3"
- not rax.success
- name: "Delete integration 3"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-3"
state: absent
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 3"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success[0].name == "{{ resource_prefix }}-3"
- rax.success[0].rax_status == "DELETED"
# ============================================================
# ============================================================
- name: Test rax basic idempotency multi server 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-4"
count: 2
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency multi server 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- name: Test rax basic idempotency multi server 2
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-4"
count: 2
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency multi server 2
assert:
that:
- rax is successful
- rax is not changed
- not rax.action
- rax.instances|length == 2
- not rax.success
- name: Test rax basic idempotency multi server 3
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-4"
count: 3
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency multi server 3
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 3
- rax.success|length == 1
- name: "Delete integration 4"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-4"
count: 3
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 4"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 3
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group without exact_count 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-5-%02d"
count: 2
group: "{{ resource_prefix }}-5"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|length == 2
- name: "Test delete integration 5"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-5-%02d"
count: 2
group: "{{ resource_prefix }}-5"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
- name: "Validate delete integration 5"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 2
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group without exact_count non-idempotency 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-6-%02d"
count: 2
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count non-idempotency 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|length == 2
- name: Test rax multi server group without exact_count non-idempotency 2
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-6-%02d"
count: 2
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count non-idempotency 2
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 4
- rax.instances|map(attribute='rax_name')|unique|length == 4
- name: "Test delete integration 6"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-6-%02d"
count: 4
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
- name: "Validate delete integration 6"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 4
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group with exact_count 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-7-%02d"
count: 2
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|length == 2
- name: Test rax multi server group with exact_count 2
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-7-%02d"
count: 2
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 2
assert:
that:
- rax is successful
- rax is not changed
- not rax.action
- rax.instances|length == 2
- rax.instances|map(attribute='rax_name')|unique|length == 2
- name: Test rax multi server group with exact_count 3
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-7-%02d"
count: 4
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 3
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 4
- rax.success|length == 2
- rax.instances|map(attribute='rax_name')|unique|length == 4
- name: "Test delete integration 7"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-7-%02d"
count: 0
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 7"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 4
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group without exact_count and disabled auto_increment 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-8"
count: 2
group: "{{ resource_prefix }}-8"
auto_increment: false
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count and disabled auto_increment 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|length == 1
- name: "Test delete integration 8"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-8"
count: 2
group: "{{ resource_prefix }}-8"
auto_increment: false
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
- name: "Validate delete integration 8"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 2
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group with exact_count and no printf 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-9"
count: 2
exact_count: true
group: "{{ resource_prefix }}-9"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and no printf 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|list|sort == ['{{ resource_prefix }}-91', '{{ resource_prefix }}-92']
- name: "Test delete integration 9"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-9"
count: 0
exact_count: true
group: "{{ resource_prefix }}-9"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 9"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 2
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group with exact_count and offset 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-10-%03d"
count: 2
count_offset: 10
exact_count: true
group: "{{ resource_prefix }}-10"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and offset 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|list|sort == ['{{ resource_prefix }}-10-010', '{{ resource_prefix }}-10-011']
- name: "Test delete integration 10"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-10-%03d"
count: 0
count_offset: 10
exact_count: true
group: "{{ resource_prefix }}-10"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 10"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 2
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax multi server group with exact_count and offset 1
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-11-%03d"
count: 2
count_offset: 10
exact_count: true
group: "{{ resource_prefix }}-11"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and offset 1
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 2
- rax.instances == rax.success
- rax.instances|map(attribute='rax_name')|unique|list|sort == ['{{ resource_prefix }}-11-010', '{{ resource_prefix }}-11-011']
- name: "Test delete integration 11"
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-11-%03d"
count: 0
count_offset: 10
exact_count: true
group: "{{ resource_prefix }}-11"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 11"
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'delete'
- rax.success|length == 2
- not rax.instances
# ============================================================
# ============================================================
- name: Test rax instance_ids absent 1 (create)
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-12"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax instance_ids absent 1 (create)
assert:
that:
- rax is successful
- rax is changed
- rax.action == 'create'
- rax.instances|length == 1
- rax.instances[0].name == "{{ resource_prefix }}-12"
- rax.instances[0] == rax.success[0]
- rax.instances[0].rax_status == 'ACTIVE'
- name: Test rax instance_ids absent 2 (delete)
rax:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
image: "{{ rackspace_image_id }}"
flavor: "{{ rackspace_flavor }}"
instance_ids:
- "{{ rax.success.0.rax_id }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax2
- name: Validate rax instance_ids absent 2 (delete)
assert:
that:
- rax2 is successful
- rax2 is changed
- rax2.action == 'delete'
- rax2.success.0.rax_id == rax.success.0.rax_id
# ============================================================