Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion roles/community_images/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
# The path to the venv that python dependencies will be installed
# in
community_images_venv_path: /opt/community-images-venv

# The path to the openstack cli executable
community_images_openstack_cli_path: >-
{{ community_images_venv_path }}/bin/openstack

# The directory into which images will be downloaded / converted
# If not given, a temporary directory will be used
Expand Down Expand Up @@ -47,7 +54,7 @@ community_images_azimuth_images_manifest: >-
community_images_azimuth_images: |-
{
{% for source_key, image in community_images_azimuth_images_manifest.items() %}
{% if "kubernetes_version" in image and source_key.endswith("-jammy") %}
{% if "kubernetes_version" in image and source_key.endswith("-noble") %}
{% set kube_version = image.kubernetes_version | regex_replace('^v', '') %}
{% set kube_series = kube_version.split(".")[:-1] | join("_") %}
{% set dest_key = "kube_" ~ kube_series %}
Expand Down
4 changes: 3 additions & 1 deletion roles/community_images/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
ansible.builtin.apt:
name:
- python3-pip
- python3-venv
- qemu-utils
state: present

- name: Ensure OpenStack CLI (and SDK) are available
ansible.builtin.pip:
name: python-openstackclient
executable: pip3
virtualenv: "{{ community_images_venv_path }}"
virtualenv_command: python3 -m venv

- name: Ensure OpenStack config directory exists
ansible.builtin.file:
Expand Down
32 changes: 24 additions & 8 deletions roles/community_images/tasks/upload_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
mode: "0755"

- name: "List images with name - {{ community_images_image_spec.name }}"
ansible.builtin.command: "openstack image list -f json --name {{ community_images_image_spec.name }}"
ansible.builtin.command: >-
{{ community_images_openstack_cli_path }}
image list -f json
--name {{ community_images_image_spec.name }}
changed_when: false
register: community_images_image_list_cmd

Expand All @@ -39,7 +42,10 @@
community_images_image_id: "{{ community_images_image_list | map(attribute='ID') | first }}"

- name: "Fetch pre-existing image - {{ community_images_image_spec.name }}"
ansible.builtin.command: "openstack image show -f json {{ community_images_image_id }}"
ansible.builtin.command: >-
{{ community_images_openstack_cli_path }}
image show -f json
{{ community_images_image_id }}
changed_when: false
register: community_images_image_info

Expand Down Expand Up @@ -109,7 +115,7 @@
# Instead, we use the OpenStack CLI directly
- name: "Upload image - {{ community_images_image_spec.name }}"
ansible.builtin.command: >-
openstack image create
{{ community_images_openstack_cli_path }} image create
-f json
--container-format {{ community_images_image_spec.container_format }}
--disk-format {{ community_images_disk_format }}
Expand Down Expand Up @@ -145,14 +151,18 @@

- name: "Set image visibility - {{ community_images_image_spec.name }}"
ansible.builtin.command: >-
openstack image set --{{ community_images_image_visibility }} {{ community_images_image_id }}
{{ community_images_openstack_cli_path }}
image set
--{{ community_images_image_visibility }}
{{ community_images_image_id }}
when: community_images_image_visibility != community_images_image_current_visibility
changed_when: true

- name: "Set custom properties for image - {{ community_images_image_spec.name }}"
ansible.builtin.command: >-
openstack image set
{%- for property in community_images_custom_properties %}
{{ community_images_openstack_cli_path }}
image set
{%- for property in community_images_custom_properties %}
--property {{ property | quote }}
{%- endfor %}
{{ community_images_image_id }}
Expand All @@ -163,7 +173,10 @@
when: "community_images_image_visibility == 'shared'"
block:
- name: "Share image with project - {{ community_images_image_spec.name }}"
ansible.builtin.command: "openstack image add project {{ community_images_image_id }} {{ project_id }}"
ansible.builtin.command: >-
{{ community_images_openstack_cli_path }}
image add project
{{ community_images_image_id }} {{ project_id }}
register: community_images_image_add_project
changed_when: community_images_image_add_project.rc == 0
failed_when: >-
Expand All @@ -174,7 +187,10 @@
loop_var: project_id

- name: "Accept image into project - {{ community_images_image_spec.name }}"
ansible.builtin.command: "openstack image set --accept {{ community_images_image_id }}"
ansible.builtin.command: >-
{{ community_images_openstack_cli_path }}
image set
--accept {{ community_images_image_id }}
environment:
OS_CLOUD: "{{ project_key }}"
loop: "{{ community_images_share_projects | map(attribute='key') | list }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/infra/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ infra_floatingip_pool:
infra_image_id:
# OR
# The name of the image to upload (should be changed when the image changes)
infra_image_name: ubuntu-jammy-20250508
infra_image_name: ubuntu-noble-20250610
# The source URL for the image
infra_image_source_url: https://cloud-images.ubuntu.com/releases/jammy/release-20250508/ubuntu-22.04-server-cloudimg-amd64.img
infra_image_source_url: https://cloud-images.ubuntu.com/releases/noble/release-20250610/ubuntu-24.04-server-cloudimg-amd64.img
# The disk format of the image as downloaded
infra_image_source_disk_format: qcow2
# The container format for the image
Expand Down
1 change: 1 addition & 0 deletions roles/infra/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
name: azimuth_cloud.azimuth_ops.community_images
tasks_from: upload_image
vars:
community_images_openstack_cli_path: openstack
community_images_image_spec:
name: "{{ infra_image_name }}"
source_url: "{{ infra_image_source_url }}"
Expand Down
Loading