Files
Jakob Meng 41299b9666 Refactored stack module and use stack's tag(s) attribute
Dropped stack status checks for CREATE_COMPLETE and UPDATE_\
COMPLETE and instead pass wait=True to openstacksdk's create_stack()
and update_stack() calls because those will call event_utils.\
poll_for_events() which garantees that stack has reached those
states when they return [1],[2].

Check for duplicate keys in parameters which already have been
defined by regular module attributes. Raise an error to warn
users that they tried to overwrite parameters which they already
specified with module attributes.

Renamed stack's module attribute 'tag' to 'tags' to match both
openstacksdk and OpenStack API and clarify that more than a
single tag can be specified. Added 'tag' as an alias to keep
backward compatibility.

Actually pass the 'tags' aka 'tag' attribute to stack create
and update functions of the openstacksdk which was lost in [3].
Added tags to integration tests.

Sorted argument specs and documentation of the stack module and
marked attributes which are not updatable.

Dropped condition from self.conn.delete_stack() because the latter
will only return False when a stack could not be found which we
already. self.conn.delete_stack() will raise an exception when
stack deletion fails.

Renamed ci integration tests from 'orchestration' to 'stack' in
order to match module name and adapted tags accordingly.

Fixed and enabled ci integration tests for stack and stack_info
modules.

Dropped 'stack_name' from module return values in RETURN
docstring and ci integration tests because openstacksdk not
return this attribute.

[1] 9b1c433352/openstack/cloud/_orchestration.py (L92)
[2] 9b1c433352/openstack/cloud/_orchestration.py (L148)
[3] af79857bfb

Change-Id: I4ace6012112bbcce9094353e27eb4066cf25f229
2022-10-07 19:08:28 +00:00

90 lines
2.3 KiB
YAML

---
- name: Create minimal stack
openstack.cloud.stack:
cloud: "{{ cloud }}"
template: "roles/stack/files/hello-world.yaml"
name: "{{ stack_name }}"
tags: "tag1,tag2"
register: stack
- name: Assert fields returned by create stack
assert:
that: item in stack.stack
loop: "{{ expected_fields }}"
- name: List stacks
openstack.cloud.stack_info:
cloud: "{{ cloud }}"
register: stacks
- name: Assert stack_info module return values
assert:
that:
- stacks.stacks|length > 0
- name: Assert fields returned by stack info
assert:
that: item in stacks.stacks[0]
loop: "{{ expected_fields }}"
- name: Get single stack
openstack.cloud.stack_info:
cloud: "{{ cloud }}"
name: "{{ stack_name }}"
register: stacks
- name: Assert single stack
assert:
that:
- stacks.stacks|length == 1
- stacks.stacks.0.name == stack_name
- stacks.stacks.0.id == stack.stack.id
# Older openstacksdk releases use datatype list instead of str for tags
# Ref.: https://review.opendev.org/c/openstack/openstacksdk/+/860534
- stacks.stacks.0.tags|string in ["tag1,tag2", "['tag1', 'tag2']"]
- name: Update stack
openstack.cloud.stack:
cloud: "{{ cloud }}"
template: "roles/stack/files/hello-world.yaml"
name: "{{ stack_name }}"
tags: "tag1,tag2,tag3"
register: stack_updated
- name: Assert updated stack
assert:
that:
- stack_updated.stack.id == stack.stack.id
- stack_updated is changed
- name: Get updated stack
openstack.cloud.stack_info:
cloud: "{{ cloud }}"
name: "{{ stack_name }}"
register: stacks
- name: Assert updated stack
assert:
that:
- stacks.stacks|length == 1
- stacks.stacks.0.id == stack.stack.id
# Older openstacksdk releases use datatype list instead of str for tags
# Ref.: https://review.opendev.org/c/openstack/openstacksdk/+/860534
- stacks.stacks.0.tags|string in ["tag1,tag2,tag3", "['tag1', 'tag2', 'tag3']"]
- name: Delete stack
openstack.cloud.stack:
cloud: "{{ cloud }}"
name: "{{ stack_name }}"
state: absent
- name: Get single stack
openstack.cloud.stack_info:
cloud: "{{ cloud }}"
name: "{{ stack_name }}"
register: stacks
- assert:
that:
- (stacks.stacks|length == 0) or (stacks.stacks.0.status == 'DELETE_COMPLETE')