Merge "Delegate tasks from the tobiko-cleanup role to undercloud"

This commit is contained in:
Zuul 2023-09-13 15:04:47 +00:00 committed by Gerrit Code Review
commit 372cb72ce7
3 changed files with 24 additions and 19 deletions

View File

@ -1,4 +1,8 @@
---
- name: "from which host the cleanup will be executed"
set_fact:
cleanup_delegate_to: '{{ groups.get("undercloud", []) | first | default(test_host) }}'
- block:
- include_role: name=tobiko-ir-jenkins
when: "(lookup('env','JENKINS_URL') | length) > 0"
@ -59,7 +63,10 @@
rescue:
- name: "clean up heat stacks generated during tobiko tests"
include_role: name=tobiko-cleanup
include_role:
name: tobiko-cleanup
apply:
delegate_to: '{{ cleanup_delegate_to }}'
when: stacks_cleanup
- name: "finalize test execution"
@ -71,7 +78,10 @@
- name: "clean up heat stacks generated during tobiko tests"
include_role: name=tobiko-cleanup
include_role:
name: tobiko-cleanup
apply:
delegate_to: '{{ cleanup_delegate_to }}'
when: stacks_cleanup
- name: "finalize test execution"

View File

@ -1,4 +1,4 @@
---
# OpenStack client credentials
stackrc_file: '{{ ansible_user_dir }}/overcloudrc'
# OpenStack command
openstack_cmd: 'openstack --os-cloud overcloud'

View File

@ -1,18 +1,16 @@
---
- name: "cleanup Loadbalancers created by Tobiko tests"
shell: |
source {{ stackrc_file }}
openstack loadbalancer list -f value -c 'name' | \
{{ openstack_cmd }} loadbalancer list -f value -c 'name' | \
grep "^tobiko\." | \
xargs -r openstack loadbalancer delete --cascade --wait
xargs -r {{ openstack_cmd }} loadbalancer delete --cascade --wait
ignore_errors: yes
- name: "cleanup Heat stacks created by Tobiko tests"
shell: |
source {{ stackrc_file }}
openstack stack list -f value -c 'Stack Name' | \
{{ openstack_cmd }} stack list -f value -c 'Stack Name' | \
grep "^tobiko\." | \
xargs -r timeout 180 openstack stack delete -y --wait
xargs -r timeout 180 {{ openstack_cmd }} stack delete -y --wait
register: result
retries: 5
delay: 5
@ -21,24 +19,21 @@
- name: "cleanup subnet pools created by Tobiko tests"
shell: |
source {{ stackrc_file }}
openstack subnet pool list -f value -c 'Name' | \
{{ openstack_cmd }} subnet pool list -f value -c 'Name' | \
grep "^tobiko\." | \
xargs -r openstack subnet pool delete
xargs -r {{ openstack_cmd }} subnet pool delete
ignore_errors: yes
- name: "cleanup Security Groups created by Tobiko tests"
shell: |
source {{ stackrc_file }}
openstack security group list -f value -c 'Name' | \
{{ openstack_cmd }} security group list -f value -c 'Name' | \
grep "^tobiko\." | \
xargs -r openstack security group delete
xargs -r {{ openstack_cmd }} security group delete
ignore_errors: yes
- name: "cleanup Glance images created by Tobiko tests"
shell: |
source {{ stackrc_file }}
openstack image list -f value -c 'Name' | \
{{ openstack_cmd }} image list -f value -c 'Name' | \
grep "^tobiko\." | \
xargs -r openstack image delete
xargs -r {{ openstack_cmd }} image delete
ignore_errors: yes