Skip to content

Commit

Permalink
Merge pull request #1112 from stackhpc/bugfix/amphora
Browse files Browse the repository at this point in the history
Fix build and rotation of amphora images on Rocky 9
  • Loading branch information
jovial authored Jul 5, 2024
2 parents a8475a0 + 785eb88 commit 91db1ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
8 changes: 8 additions & 0 deletions etc/kayobe/ansible/octavia-amphora-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
vars:
amphora_dib_upper_constraints_file: "{{ pip_upper_constraints_file }}"
tasks:
- name: Install EPEL
package:
name: epel-release
become: true
when:
- ansible_facts.os_family == "RedHat"
- dnf_custom_repos | falsy

- name: Ensure packages are installed
become: true
vars:
Expand Down
29 changes: 18 additions & 11 deletions etc/kayobe/ansible/octavia-amphora-image-register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,29 @@
lookup('env', 'OS_USERNAME') != 'octavia' or
lookup('env', 'OS_PROJECT_NAME') != 'service'
- name: Get image checksum
stat:
path: "{{ image_cache_path }}/amphora-x64-haproxy-{{ openstack_release }}.qcow2"
checksum_algorithm: md5
changed_when: false
register: image_checksum

- name: Assert that Amphora image exists
assert:
that: image_checksum.stat.exists
fail_msg: |
The amphora image: {{ image_cache_path }}/amphora-x64-haproxy-{{ openstack_release }}.qcow2
does not exist. Did you build the image?
- name: Set up openstack virtualenv
pip:
virtualenv: "{{ venv }}"
virtualenv_command: python3 -m venv
name:
- openstacksdk
- python-openstackclient
state: latest
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
extra_args: "{% if openstacksdk_upper_constraints_file %}-c {{ openstacksdk_upper_constraints_file }}{% endif %}"

- name: Query Octavia Amphora image
vars:
Expand All @@ -33,23 +48,15 @@
image: amphora-x64-haproxy
register: image_info

- name: Get image checksum
stat:
path: "{{ image_cache_path }}/amphora-x64-haproxy-{{ openstack_release }}.qcow2"
checksum_algorithm: md5
changed_when: false
register: image_checksum
when: image_info.openstack_image

- name: Ensure Octavia Amphora image is renamed
vars:
ansible_python_interpreter: "{{ venv }}/bin/python"
shell:
cmd: >-
{{ venv }}/bin/openstack image set amphora-x64-haproxy --name amphora-x64-haproxy-{{ ansible_facts.date_time.iso8601_basic_short }}
when:
- image_info.openstack_image
- image_info.openstack_image.checksum != image_checksum.stat.checksum
- image_info.image
- image_info.image.checksum != image_checksum.stat.checksum
changed_when: true
environment: "{{ openstack_auth_env }}"

Expand Down

0 comments on commit 91db1ae

Please sign in to comment.