From cd002a55550f40d06bc47e7e04c096fb5df8ea01 Mon Sep 17 00:00:00 2001 From: Jakob Meng <code@jakobmeng.de> Date: Wed, 5 Oct 2022 21:11:16 +0200 Subject: [PATCH] Use module defaults groups in ci integration tests to reduce code bloat Change-Id: I1370f5bcde602f63b4763c487f027677e79c73b0 --- .../tasks/main.yml | 18 +- ci/roles/keystone_idp/tasks/main.yml | 6 +- ci/roles/keystone_mapping/tasks/main.yml | 6 +- ci/roles/object_container/tasks/main.yml | 5 +- ci/roles/quota/defaults/main.yml | 3 - ci/roles/quota/tasks/main.yml | 260 +++++++++--------- 6 files changed, 149 insertions(+), 149 deletions(-) diff --git a/ci/roles/keystone_federation_protocol/tasks/main.yml b/ci/roles/keystone_federation_protocol/tasks/main.yml index d717891..3a76818 100644 --- a/ci/roles/keystone_federation_protocol/tasks/main.yml +++ b/ci/roles/keystone_federation_protocol/tasks/main.yml @@ -6,21 +6,21 @@ # - Retry change (noop) # - module_defaults: - # meta/action_groups.yml glue seems to be missing - # group/os: - # cloud: "{{ cloud }}" + group/openstack.cloud.openstack: + 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: cloud: "{{ cloud }}" openstack.cloud.federation_idp: cloud: "{{ cloud }}" openstack.cloud.federation_mapping: 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: # ======================================================================== # Initial setup diff --git a/ci/roles/keystone_idp/tasks/main.yml b/ci/roles/keystone_idp/tasks/main.yml index 2d76aac..4c77f18 100644 --- a/ci/roles/keystone_idp/tasks/main.yml +++ b/ci/roles/keystone_idp/tasks/main.yml @@ -6,9 +6,9 @@ # - Retry change (noop) # - module_defaults: - # meta/action_groups.yml glue seems to be missing - # group/os: - # cloud: "{{ cloud }}" + group/openstack.cloud.openstack: + cloud: "{{ cloud }}" + # Backward compatibility with Ansible 2.9 openstack.cloud.identity_domain: cloud: "{{ cloud }}" openstack.cloud.federation_idp: diff --git a/ci/roles/keystone_mapping/tasks/main.yml b/ci/roles/keystone_mapping/tasks/main.yml index 68e761d..48c35d1 100644 --- a/ci/roles/keystone_mapping/tasks/main.yml +++ b/ci/roles/keystone_mapping/tasks/main.yml @@ -1,8 +1,8 @@ --- - module_defaults: - # meta/action_groups.yml glue seems to be missing - # group/os: - # cloud: "{{ cloud }}" + group/openstack.cloud.openstack: + cloud: "{{ cloud }}" + # Backward compatibility with Ansible 2.9 openstack.cloud.federation_mapping: cloud: "{{ cloud }}" openstack.cloud.federation_mapping_info: diff --git a/ci/roles/object_container/tasks/main.yml b/ci/roles/object_container/tasks/main.yml index 0e099ef..9787463 100644 --- a/ci/roles/object_container/tasks/main.yml +++ b/ci/roles/object_container/tasks/main.yml @@ -1,5 +1,8 @@ --- - module_defaults: + group/openstack.cloud.openstack: + cloud: "{{ cloud }}" + # Backward compatibility with Ansible 2.9 openstack.cloud.object_container: cloud: "{{ cloud }}" block: @@ -57,4 +60,4 @@ openstack.cloud.object_container: container: "{{ container_name }}" state: absent - ignore_errors: yes \ No newline at end of file + ignore_errors: yes diff --git a/ci/roles/quota/defaults/main.yml b/ci/roles/quota/defaults/main.yml index c9a1ce7..eafed1c 100644 --- a/ci/roles/quota/defaults/main.yml +++ b/ci/roles/quota/defaults/main.yml @@ -1,7 +1,4 @@ test_project: ansible_project -quota_name_frag: - cloud: "{{ cloud }}" - name: "{{ test_project }}" test_network_quota: floating_ips: 5 networks: 50 diff --git a/ci/roles/quota/tasks/main.yml b/ci/roles/quota/tasks/main.yml index 0415db4..10475a9 100644 --- a/ci/roles/quota/tasks/main.yml +++ b/ci/roles/quota/tasks/main.yml @@ -1,131 +1,131 @@ --- -- name: Create test project - openstack.cloud.project: - cloud: "{{ cloud }}" - state: present - name: "{{ test_project }}" - -- name: Clear quotas before tests - openstack.cloud.quota: - cloud: "{{ cloud }}" - state: absent - name: "{{ test_project }}" - register: default_quotas - -- name: Set network quota - openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Assert changed - assert: - that: quotas is changed - -- name: Assert field values - assert: - that: quotas.quotas.network[item.key] == item.value - loop: "{{ test_network_quota | dict2items }}" - -- name: Set network quota again - openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Assert not changed - assert: - that: quotas is not changed - -- name: Set volume quotas - openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Assert changed - assert: - that: quotas is changed - -- name: Assert field values - assert: - that: quotas.quotas.volume[item.key] == item.value - loop: "{{ test_volume_quota | dict2items }}" - -- name: Set volume quotas again - openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Assert not changed - assert: - that: quotas is not changed - -- name: Set compute quotas - openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Assert changed - assert: - that: quotas is changed - -- name: Assert field values - assert: - that: quotas.quotas.compute[item.key] == item.value - loop: "{{ test_compute_quota | dict2items }}" - -- name: Set compute quotas again - openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}" - register: quotas - -- name: Unset all quotas - openstack.cloud.quota: - cloud: "{{ cloud }}" - name: "{{ test_project }}" - state: absent - register: quotas - -- name: Assert defaults restore - assert: - that: quotas.quotas == default_quotas.quotas - -- name: Set all quotas at once - openstack.cloud.quota: - "{{ [test_network_quota, test_volume_quota, test_compute_quota, - quota_name_frag] | combine }}" - register: quotas - -- name: Assert changed - assert: - that: quotas is changed - -- name: Assert volume values - assert: - that: quotas.quotas.volume[item.key] == item.value - loop: "{{ test_volume_quota | dict2items }}" - -- name: Assert network values - assert: - that: quotas.quotas.network[item.key] == item.value - loop: "{{ test_network_quota | dict2items }}" - -- name: Assert compute values - assert: - that: quotas.quotas.compute[item.key] == item.value - loop: "{{ test_compute_quota | dict2items }}" - -- name: Set all quotas at once again - openstack.cloud.quota: - "{{ [test_network_quota, test_volume_quota, test_compute_quota, - quota_name_frag] | combine }}" - register: quotas - -- name: Assert not changed - assert: - that: quotas is not changed - -- name: Unset all quotas - openstack.cloud.quota: - cloud: "{{ cloud }}" - name: "{{ test_project }}" - state: absent - register: quotas - -- name: Delete test project - openstack.cloud.project: - cloud: "{{ cloud }}" - state: absent - name: "{{ test_project }}" +- module_defaults: + group/openstack.cloud.openstack: + cloud: "{{ cloud }}" + name: "{{ test_project }}" + # Backward compatibility with Ansible 2.9 + openstack.cloud.project: + cloud: "{{ cloud }}" + name: "{{ test_project }}" + openstack.cloud.quota: + cloud: "{{ cloud }}" + 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 + + - name: Set network quota + openstack.cloud.quota: "{{ test_network_quota }}" + register: quotas + + - name: Assert changed + assert: + that: quotas is changed + + - name: Assert field values + assert: + that: quotas.quotas.network[item.key] == item.value + loop: "{{ test_network_quota | dict2items }}" + + - name: Set network quota again + openstack.cloud.quota: "{{ test_network_quota }}" + register: quotas + + - name: Assert not changed + assert: + that: quotas is not changed + + - name: Set volume quotas + openstack.cloud.quota: "{{ test_volume_quota }}" + register: quotas + + - name: Assert changed + assert: + that: quotas is changed + + - name: Assert field values + assert: + that: quotas.quotas.volume[item.key] == item.value + loop: "{{ test_volume_quota | dict2items }}" + + - name: Set volume quotas again + openstack.cloud.quota: "{{ test_volume_quota }}" + register: quotas + + - name: Assert not changed + assert: + that: quotas is not changed + + - name: Set compute quotas + openstack.cloud.quota: "{{ test_compute_quota }}" + register: quotas + + - name: Assert changed + assert: + that: quotas is changed + + - name: Assert field values + assert: + that: quotas.quotas.compute[item.key] == item.value + loop: "{{ test_compute_quota | dict2items }}" + + - name: Set compute quotas again + openstack.cloud.quota: "{{ test_compute_quota }}" + register: quotas + + - name: Unset all quotas + openstack.cloud.quota: + state: absent + register: quotas + + - name: Assert defaults restore + assert: + that: quotas.quotas == default_quotas.quotas + + - name: Set all quotas at once + openstack.cloud.quota: + "{{ [test_network_quota, test_volume_quota, test_compute_quota] | combine }}" + register: quotas + + - name: Assert changed + assert: + that: quotas is changed + + - name: Assert volume values + assert: + that: quotas.quotas.volume[item.key] == item.value + loop: "{{ test_volume_quota | dict2items }}" + + - name: Assert network values + assert: + that: quotas.quotas.network[item.key] == item.value + loop: "{{ test_network_quota | dict2items }}" + + - name: Assert compute values + assert: + that: quotas.quotas.compute[item.key] == item.value + loop: "{{ test_compute_quota | dict2items }}" + + - name: Set all quotas at once again + openstack.cloud.quota: + "{{ [test_network_quota, test_volume_quota, test_compute_quota] | combine }}" + register: quotas + + - name: Assert not changed + assert: + that: quotas is not changed + + - name: Unset all quotas + openstack.cloud.quota: + state: absent + register: quotas + + - name: Delete test project + openstack.cloud.project: + state: absent -- GitLab