Files
ansible-collections-openstack/ci/roles/resource/tasks/check_mode.yml
Jakob Meng a4a6e6d4ec Added resource{,s} modules
Change-Id: I0b04d43d5095ee74ec5af27013b6159a6a4d0f13
2023-01-26 09:34:30 +01:00

195 lines
5.9 KiB
YAML

---
- module_defaults:
group/openstack.cloud.openstack:
cloud: "{{ cloud }}"
# Listing modules individually is required for
# backward compatibility with Ansible 2.9 only
openstack.cloud.resource:
cloud: "{{ cloud }}"
openstack.cloud.resources:
cloud: "{{ cloud }}"
block:
- name: Create security group
check_mode: false
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
description: 'ansible security group'
register: security_group
- name: Assert created security group
assert:
that:
- security_group.resource.name == 'ansible_security_group'
- security_group.resource.description == 'ansible security group'
- name: Find created security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert created security group independently
assert:
that:
- security_groups.resources | length == 1
- security_groups.resources.0.name == 'ansible_security_group'
- security_groups.resources.0.description == 'ansible security group'
- name: Update security group simulation
check_mode: true
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
description: 'ansible neutron security group'
register: security_group
- name: Assert security group update simulation
assert:
that:
- security_group is changed
- security_group.resource.description == 'ansible neutron security group'
- name: Find non-updated security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert security group non-update
assert:
that:
- security_groups.resources | length == 1
- security_groups.resources.0.name == 'ansible_security_group'
- security_groups.resources.0.description == 'ansible security group'
- name: Update security group
check_mode: false
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
description: 'ansible neutron security group'
register: security_group
- name: Assert security group update
assert:
that:
- security_group is changed
- security_group.resource.description == 'ansible neutron security group'
- name: Find updated security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert security group update
assert:
that:
- security_groups.resources | length == 1
- security_groups.resources.0.name == 'ansible_security_group'
- security_groups.resources.0.description == 'ansible neutron security group'
- name: Delete security group simulation
check_mode: true
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
state: absent
register: security_group
- name: Assert security group delete simulation
assert:
that:
- security_group is changed
- "'security_group' not in security_group"
- name: Find non-deleted security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert security group non-deletion
assert:
that:
- security_groups.resources | length == 1
- security_groups.resources.0.name == 'ansible_security_group'
- security_groups.resources.0.description == 'ansible neutron security group'
- name: Delete security group
check_mode: false
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
state: absent
register: security_group
- name: Assert security group deletion
assert:
that:
- security_group is changed
- "'resource' not in security_group"
- name: Find deleted security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert security group deletion
assert:
that:
- security_groups.resources | length == 0
- name: Create security group simulation
check_mode: true
openstack.cloud.resource:
service: network
type: security_group
attributes:
name: ansible_security_group
description: 'ansible security group'
register: security_group
- name: Assert security group creation simulation
assert:
that:
- security_group is changed
- security_group.resource.name == 'ansible_security_group'
- security_group.resource.description == 'ansible security group'
- security_group.resource.keys() | sort == ['description', 'name'] | sort
- name: Find non-created security group
openstack.cloud.resources:
service: network
type: security_group
parameters:
name: ansible_security_group
register: security_groups
- name: Assert security group non-creation
assert:
that:
- security_groups.resources | length == 0