openstack-ansible-os_ironic/tasks/ironic_deploy_image.yml
Jonathan Rosser b974a6c0e0 Refactor ironic deploy image handling.
The deploy image is required in two places in an ironic deployment,
first as images uploaded to glance for the ironic service, and second
as files on a web server for the ironic-inspector service.

Previously this role only placed the deploy images on the ironic
inspector web server, but this patch provides the functionality to
also upload the images to glance.

The variables for ironic deploy image source locations are
consolidated so that only one set are required to run the tasks
for both ironic and ironic-inspector, and several overrides are
available allowing the source to be overidden to a local mirror
easily.

Finally - the name of the files placed on the inspector web server
and into glance represent the upstream name of the image files rather
than generic names which lose versioning and release information.

Change-Id: I1aed9d97a4ddbfb70d2375f5204c55374d1067c9
2022-12-07 15:03:32 +01:00

54 lines
1.9 KiB
YAML

---
# Copyright 2022, BBC R&D
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# We set the python interpreter to the ansible runtime venv if
# the delegation is to localhost so that we get access to the
# appropriate python libraries in that venv. If the delegation
# is to another host, we assume that it is accessible by the
# system python instead.
- name: Setup the deploy image
delegate_to: "{{ ironic_service_setup_host }}"
vars:
ansible_python_interpreter: "{{ ironic_service_setup_host_python_interpreter }}"
block:
- name: Create image download directory
file:
path: "{{ ironic_deploy_image_path }}"
state: directory
mode: "0750"
owner: "{{ ironic_deploy_image_path_owner }}"
- name: Download image from artefact server
get_url:
url: "{{ item['url'] }}"
dest: "{{ ironic_deploy_image_path }}"
checksum: "sha256:{{ item['sha_url'] }}"
retries: 10
delay: 10
register: ironic_download_results
with_items:
- "{{ ironic_deploy_image_list }}"
- name: Upload images
openstack.cloud.image:
cloud: default
endpoint_type: admin
name: "{{ item.item.name }}"
container_format: "{{ item.item.container_format }}"
disk_format: "{{ item.item.disk_format }}"
filename: "{{ item.dest }}"
with_items:
- "{{ ironic_download_results.results }}"