Use module defaults groups in ci integration tests to reduce code bloat

Change-Id: I1370f5bcde602f63b4763c487f027677e79c73b0
This commit is contained in:
Jakob Meng
2022-10-05 21:11:16 +02:00
parent d0ac32eefd
commit cd002a5555
6 changed files with 123 additions and 123 deletions

View File

@@ -6,21 +6,21 @@
# - Retry change (noop) # - Retry change (noop)
# #
- module_defaults: - module_defaults:
# meta/action_groups.yml glue seems to be missing group/openstack.cloud.openstack:
# group/os: cloud: "{{ cloud }}"
# cloud: "{{ cloud }}" openstack.cloud.keystone_federation_protocol:
cloud: "{{ cloud }}" # Backward compatibility with Ansible 2.9
idp_id: "{{ idp_name }}"
openstack.cloud.keystone_federation_protocol_info:
cloud: "{{ cloud }}" # Backward compatibility with Ansible 2.9
idp_id: "{{ idp_name }}"
# Backward compatibility with Ansible 2.9
openstack.cloud.identity_domain: openstack.cloud.identity_domain:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
openstack.cloud.federation_idp: openstack.cloud.federation_idp:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
openstack.cloud.federation_mapping: openstack.cloud.federation_mapping:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
openstack.cloud.keystone_federation_protocol:
cloud: "{{ cloud }}"
idp_id: "{{ idp_name }}"
openstack.cloud.keystone_federation_protocol_info:
cloud: "{{ cloud }}"
idp_id: "{{ idp_name }}"
block: block:
# ======================================================================== # ========================================================================
# Initial setup # Initial setup

View File

@@ -6,9 +6,9 @@
# - Retry change (noop) # - Retry change (noop)
# #
- module_defaults: - module_defaults:
# meta/action_groups.yml glue seems to be missing group/openstack.cloud.openstack:
# group/os: cloud: "{{ cloud }}"
# cloud: "{{ cloud }}" # Backward compatibility with Ansible 2.9
openstack.cloud.identity_domain: openstack.cloud.identity_domain:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
openstack.cloud.federation_idp: openstack.cloud.federation_idp:

View File

@@ -1,8 +1,8 @@
--- ---
- module_defaults: - module_defaults:
# meta/action_groups.yml glue seems to be missing group/openstack.cloud.openstack:
# group/os: cloud: "{{ cloud }}"
# cloud: "{{ cloud }}" # Backward compatibility with Ansible 2.9
openstack.cloud.federation_mapping: openstack.cloud.federation_mapping:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
openstack.cloud.federation_mapping_info: openstack.cloud.federation_mapping_info:

View File

@@ -1,5 +1,8 @@
--- ---
- module_defaults: - module_defaults:
group/openstack.cloud.openstack:
cloud: "{{ cloud }}"
# Backward compatibility with Ansible 2.9
openstack.cloud.object_container: openstack.cloud.object_container:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
block: block:

View File

@@ -1,7 +1,4 @@
test_project: ansible_project test_project: ansible_project
quota_name_frag:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
test_network_quota: test_network_quota:
floating_ips: 5 floating_ips: 5
networks: 50 networks: 50

View File

@@ -1,131 +1,131 @@
--- ---
- name: Create test project - module_defaults:
group/openstack.cloud.openstack:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
# Backward compatibility with Ansible 2.9
openstack.cloud.project: openstack.cloud.project:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
state: present
name: "{{ test_project }}" name: "{{ test_project }}"
- name: Clear quotas before tests
openstack.cloud.quota: openstack.cloud.quota:
cloud: "{{ cloud }}" cloud: "{{ cloud }}"
state: absent
name: "{{ test_project }}" name: "{{ test_project }}"
block:
- name: Create test project
openstack.cloud.project:
state: present
- name: Clear quotas before tests
openstack.cloud.quota:
state: absent
register: default_quotas register: default_quotas
- name: Set network quota - name: Set network quota
openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_network_quota }}"
register: quotas register: quotas
- name: Assert changed - name: Assert changed
assert: assert:
that: quotas is changed that: quotas is changed
- name: Assert field values - name: Assert field values
assert: assert:
that: quotas.quotas.network[item.key] == item.value that: quotas.quotas.network[item.key] == item.value
loop: "{{ test_network_quota | dict2items }}" loop: "{{ test_network_quota | dict2items }}"
- name: Set network quota again - name: Set network quota again
openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_network_quota }}"
register: quotas register: quotas
- name: Assert not changed - name: Assert not changed
assert: assert:
that: quotas is not changed that: quotas is not changed
- name: Set volume quotas - name: Set volume quotas
openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_volume_quota }}"
register: quotas register: quotas
- name: Assert changed - name: Assert changed
assert: assert:
that: quotas is changed that: quotas is changed
- name: Assert field values - name: Assert field values
assert: assert:
that: quotas.quotas.volume[item.key] == item.value that: quotas.quotas.volume[item.key] == item.value
loop: "{{ test_volume_quota | dict2items }}" loop: "{{ test_volume_quota | dict2items }}"
- name: Set volume quotas again - name: Set volume quotas again
openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_volume_quota }}"
register: quotas register: quotas
- name: Assert not changed - name: Assert not changed
assert: assert:
that: quotas is not changed that: quotas is not changed
- name: Set compute quotas - name: Set compute quotas
openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_compute_quota }}"
register: quotas register: quotas
- name: Assert changed - name: Assert changed
assert: assert:
that: quotas is changed that: quotas is changed
- name: Assert field values - name: Assert field values
assert: assert:
that: quotas.quotas.compute[item.key] == item.value that: quotas.quotas.compute[item.key] == item.value
loop: "{{ test_compute_quota | dict2items }}" loop: "{{ test_compute_quota | dict2items }}"
- name: Set compute quotas again - name: Set compute quotas again
openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}" openstack.cloud.quota: "{{ test_compute_quota }}"
register: quotas register: quotas
- name: Unset all quotas - name: Unset all quotas
openstack.cloud.quota: openstack.cloud.quota:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
state: absent state: absent
register: quotas register: quotas
- name: Assert defaults restore - name: Assert defaults restore
assert: assert:
that: quotas.quotas == default_quotas.quotas that: quotas.quotas == default_quotas.quotas
- name: Set all quotas at once - name: Set all quotas at once
openstack.cloud.quota: openstack.cloud.quota:
"{{ [test_network_quota, test_volume_quota, test_compute_quota, "{{ [test_network_quota, test_volume_quota, test_compute_quota] | combine }}"
quota_name_frag] | combine }}"
register: quotas register: quotas
- name: Assert changed - name: Assert changed
assert: assert:
that: quotas is changed that: quotas is changed
- name: Assert volume values - name: Assert volume values
assert: assert:
that: quotas.quotas.volume[item.key] == item.value that: quotas.quotas.volume[item.key] == item.value
loop: "{{ test_volume_quota | dict2items }}" loop: "{{ test_volume_quota | dict2items }}"
- name: Assert network values - name: Assert network values
assert: assert:
that: quotas.quotas.network[item.key] == item.value that: quotas.quotas.network[item.key] == item.value
loop: "{{ test_network_quota | dict2items }}" loop: "{{ test_network_quota | dict2items }}"
- name: Assert compute values - name: Assert compute values
assert: assert:
that: quotas.quotas.compute[item.key] == item.value that: quotas.quotas.compute[item.key] == item.value
loop: "{{ test_compute_quota | dict2items }}" loop: "{{ test_compute_quota | dict2items }}"
- name: Set all quotas at once again - name: Set all quotas at once again
openstack.cloud.quota: openstack.cloud.quota:
"{{ [test_network_quota, test_volume_quota, test_compute_quota, "{{ [test_network_quota, test_volume_quota, test_compute_quota] | combine }}"
quota_name_frag] | combine }}"
register: quotas register: quotas
- name: Assert not changed - name: Assert not changed
assert: assert:
that: quotas is not changed that: quotas is not changed
- name: Unset all quotas - name: Unset all quotas
openstack.cloud.quota: openstack.cloud.quota:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
state: absent state: absent
register: quotas register: quotas
- name: Delete test project - name: Delete test project
openstack.cloud.project: openstack.cloud.project:
cloud: "{{ cloud }}"
state: absent state: absent
name: "{{ test_project }}"