Do not hardcode image name and properly delete mock images in CI tests

Change-Id: I2962dd1d1c27989cbd135b051cfb3e9f8c9e3823
This commit is contained in:
Jakob Meng 2023-02-21 10:57:56 +01:00
parent edd4e1b2e9
commit b6b5f63877
2 changed files with 22 additions and 1 deletions

View File

@ -318,6 +318,15 @@
name: ansible_project
domain: default
- name: Delete mock kernel and ramdisk images
openstack.cloud.image:
cloud: "{{ cloud }}"
state: absent
name: "{{ item }}"
loop:
- cirros-vmlinuz
- cirros-initrd
- name: Delete test image file
file:
name: "{{ tmp_file.path }}"

View File

@ -1,9 +1,21 @@
---
- name: List all images
openstack.cloud.image_info:
cloud: "{{ cloud }}"
register: images
- name: Identify CirrOS image name
set_fact:
image_name: "{{ images.images|community.general.json_query(query)|first }}"
vars:
query: "[?starts_with(name, 'cirros')].name"
- name: Create server
openstack.cloud.server:
cloud: "{{ cloud }}"
state: present
name: "{{ server_name }}"
image: "cirros-0.5.2-x86_64-disk"
image: "{{ image_name }}"
flavor: "{{ flavor_name }}"
network: "{{ server_network }}"
auto_ip: false