Skip to content

Commit 56a7e85

Browse files
Generalise host image playbooks (#1390)
* Generalise image upload playbook * Replace occurences to host-image * Variable for file extension * Revert changes to overcloud image build * Update file extension variable * Use image name * s/image/artifact/g * Remove image_repository creds * Fix artifact references in host-image-build * Generalise promotion workflow
1 parent f44def7 commit 56a7e85

File tree

6 files changed

+50
-47
lines changed

6 files changed

+50
-47
lines changed

.github/workflows/overcloud-host-image-build.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,11 @@ jobs:
239239
source venvs/kayobe/bin/activate &&
240240
source src/kayobe-config/kayobe-env --environment ci-builder &&
241241
kayobe playbook run \
242-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-upload.yml \
243-
-e image_path=/opt/kayobe/images/overcloud-rocky-9 \
244-
-e host_image_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
242+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
243+
-e artifact_path=/opt/kayobe/images/overcloud-rocky-9 \
244+
-e artifact_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
245+
-e artifact_type="kayobe-images" \
246+
-e file_regex="*.qcow2" \
245247
-e os_distribution="rocky" \
246248
-e os_release="9"
247249
env:
@@ -291,9 +293,11 @@ jobs:
291293
source venvs/kayobe/bin/activate &&
292294
source src/kayobe-config/kayobe-env --environment ci-builder &&
293295
kayobe playbook run \
294-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-upload.yml \
295-
-e image_path=/opt/kayobe/images/overcloud-ubuntu-jammy \
296-
-e host_image_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
296+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
297+
-e artifact_path=/opt/kayobe/images/overcloud-ubuntu-jammy \
298+
-e artifact_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
299+
-e artifact_type="kayobe-images" \
300+
-e file_regex="*.qcow2" \
297301
-e os_distribution="ubuntu" \
298302
-e os_release="jammy"
299303
env:

.github/workflows/overcloud-host-image-promote.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ jobs:
7676
source venvs/kayobe/bin/activate &&
7777
source src/kayobe-config/kayobe-env --environment ci-builder &&
7878
kayobe playbook run \
79-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-promote.yml \
80-
-e image_path='/opt/kayobe/images/overcloud-rocky-linux-9' \
79+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-promote.yml \
80+
-e artifact_type="kayobe-images" \
8181
-e os_distribution='rocky' \
8282
-e os_release='9'
8383
env:
84-
OVERCLOUD_HOST_IMAGE_TAG: ${{ inputs.image_tag }}
84+
ARTIFACT_TAG: ${{ inputs.image_tag }}
8585
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
8686
if: inputs.rocky9
8787

@@ -90,11 +90,11 @@ jobs:
9090
source venvs/kayobe/bin/activate &&
9191
source src/kayobe-config/kayobe-env --environment ci-builder &&
9292
kayobe playbook run \
93-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-promote.yml \
94-
-e image_path='/opt/kayobe/images/overcloud-ubuntu-jammy' \
93+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-promote.yml \
94+
-e artifact_type="kayobe-images" \
9595
-e os_distribution='ubuntu' \
9696
-e os_release='jammy'
9797
env:
98-
OVERCLOUD_HOST_IMAGE_TAG: ${{ inputs.image_tag }}
98+
ARTIFACT_TAG: ${{ inputs.image_tag }}
9999
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
100100
if: inputs.ubuntu-jammy

etc/kayobe/ansible/pulp-host-image-promote.yml renamed to etc/kayobe/ansible/pulp-artifact-promote.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
---
2-
# Tag is the version of the image to promote, stored in an env variable named OVERCLOUD_HOST_IMAGE_TAG
3-
- name: Promote an image to production
2+
# Tag is the version of the artifact to promote, stored in an env variable named ARTIFACT_TAG
3+
- name: Promote an artifact to production
44
hosts: localhost
55
vars:
66
remote_pulp_url: "{{ stackhpc_release_pulp_url }}"
7-
remote_pulp_username: "{{ stackhpc_image_repository_username }}"
8-
remote_pulp_password: "{{ stackhpc_image_repository_password }}"
9-
repository_name: "kayobe-images-{{ openstack_release }}-{{ os_distribution }}-{{ os_release }}"
10-
base_path: "kayobe-images/{{ openstack_release }}/{{ os_distribution }}/{{ os_release }}"
11-
promotion_tag: "{{ lookup('env', 'OVERCLOUD_HOST_IMAGE_TAG') }}"
7+
remote_pulp_username: "{{ stackhpc_release_pulp_username }}"
8+
remote_pulp_password: "{{ stackhpc_release_pulp_password }}"
9+
repository_name: "{{ artifact_type }}-{{ openstack_release }}-{{ os_distribution }}-{{ os_release }}"
10+
pulp_base_path: "{{ artifact_type }}/{{ openstack_release }}/{{ os_distribution }}/{{ os_release }}"
11+
promotion_tag: "{{ lookup('env', 'ARTIFACT_TAG') }}"
1212
tasks:
13-
14-
- name: Check whether the image exists
13+
- name: Check whether the artifact exists
1514
pulp.squeezer.file_distribution:
1615
pulp_url: "{{ remote_pulp_url }}"
1716
username: "{{ remote_pulp_username }}"
1817
password: "{{ remote_pulp_password }}"
1918
name: "{{ repository_name }}_{{ promotion_tag }}"
20-
base_path: "{{ base_path }}/{{ promotion_tag }}"
19+
base_path: "{{ pulp_base_path }}/{{ promotion_tag }}"
2120
register: distribution_details
2221
until: distribution_details is success
2322
retries: 3
2423
delay: 5
2524

26-
- name: Fail if the image does not exist
25+
- name: Fail if the artifact does not exist
2726
fail:
28-
msg: "Image {{ promotion_tag }} does not exist"
27+
msg: "artifact {{ promotion_tag }} does not exist"
2928
when: distribution_details.distribution is none
3029

3130
- name: Ensure production content guard is set
@@ -34,7 +33,7 @@
3433
username: "{{ remote_pulp_username }}"
3534
password: "{{ remote_pulp_password }}"
3635
name: "{{ repository_name }}_{{ promotion_tag }}"
37-
base_path: "{{ base_path }}/{{ promotion_tag }}"
36+
base_path: "{{ pulp_base_path }}/{{ promotion_tag }}"
3837
content_guard: release
3938
state: present
4039
register: content_guard_result

etc/kayobe/ansible/pulp-host-image-upload.yml renamed to etc/kayobe/ansible/pulp-artifact-upload.yml

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
2-
- name: Upload and create a distribution for an image
2+
- name: Upload and create a distribution for an artifact
33
hosts: seed
44
vars:
55
remote_pulp_url: "{{ stackhpc_release_pulp_url }}"
6-
remote_pulp_username: "{{ stackhpc_image_repository_username }}"
7-
remote_pulp_password: "{{ stackhpc_image_repository_password }}"
8-
repository_name: "kayobe-images-{{ openstack_release }}-{{ os_distribution }}-{{ os_release }}"
9-
pulp_base_path: "kayobe-images/{{ openstack_release }}/{{ os_distribution }}/{{ os_release }}"
6+
remote_pulp_username: "{{ stackhpc_release_pulp_username }}"
7+
remote_pulp_password: "{{ stackhpc_release_pulp_password }}"
8+
repository_name: "{{ artifact_type }}-{{ openstack_release }}-{{ os_distribution }}-{{ os_release }}"
9+
pulp_base_path: "{{ artifact_type }}/{{ openstack_release }}/{{ os_distribution }}/{{ os_release }}"
1010
tasks:
11-
- name: Print image tag
11+
- name: Print artifact tag
1212
debug:
13-
msg: "Image tag: {{ host_image_tag }}"
13+
msg: "artifact tag: {{ artifact_tag }}"
1414

1515
- name: Get filename
1616
find:
17-
paths: "{{ image_path }}"
18-
patterns: '*.qcow2'
17+
paths: "{{ artifact_path }}"
18+
patterns: "{{ file_regex }}"
1919
register: found_files
2020

2121
- name: Upload an artifact
@@ -107,8 +107,8 @@
107107
pulp_url: "{{ remote_pulp_url }}"
108108
username: "{{ remote_pulp_username }}"
109109
password: "{{ remote_pulp_password }}"
110-
name: "{{ repository_name }}_{{ host_image_tag }}"
111-
base_path: "{{ pulp_base_path }}/{{ host_image_tag }}"
110+
name: "{{ repository_name }}_{{ artifact_tag }}"
111+
base_path: "{{ pulp_base_path }}/{{ artifact_tag }}"
112112
publication: "{{ publication_details.publication.pulp_href }}"
113113
content_guard: development
114114
state: present
@@ -118,24 +118,24 @@
118118
retries: 3
119119
delay: 5
120120

121-
- name: Update new images file with versioned path
121+
- name: Update new artifacts file with versioned path
122122
lineinfile:
123-
path: /tmp/updated_images.txt
123+
path: /tmp/updated_artifacts.txt
124124
line: "{{ remote_pulp_url }}/pulp/content/{{ pulp_base_path }}/\
125-
{{ host_image_tag }}/{{ found_files.files[0].path | basename }}"
125+
{{ artifact_tag }}/{{ found_files.files[0].path | basename }}"
126126
create: true
127127

128-
- name: Update new images file with latest path
128+
- name: Update new artifacts file with latest path
129129
lineinfile:
130-
path: /tmp/updated_images.txt
130+
path: /tmp/updated_artifacts.txt
131131
line: "{{ remote_pulp_url }}/pulp/content/{{ pulp_base_path }}/\
132132
latest/{{ found_files.files[0].path | basename }}"
133133
when: latest_distribution_details.changed
134134

135135
- name: Print versioned path
136136
debug:
137137
msg: "New versioned path: {{ remote_pulp_url }}/pulp/content/{{ pulp_base_path }}/\
138-
{{ host_image_tag }}/{{ found_files.files[0].path | basename }}"
138+
{{ artifact_tag }}/{{ found_files.files[0].path | basename }}"
139139
when: latest_distribution_details.changed
140140

141141
- name: Print latest path
@@ -146,5 +146,5 @@
146146

147147
- name: Print version tag
148148
debug:
149-
msg: "New tag: {{ host_image_tag }}"
149+
msg: "New tag: {{ artifact_tag }}"
150150
when: latest_distribution_details.changed

etc/kayobe/ansible/pulp-host-image-download.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
- name: Download image artifact
2626
get_url:
2727
url: "{{ stackhpc_overcloud_host_image_url_no_auth }}"
28-
username: "{{ stackhpc_image_repository_username }}"
29-
password: "{{ stackhpc_image_repository_password }}"
28+
username: "{{ stackhpc_release_pulp_username }}"
29+
password: "{{ stackhpc_release_pulp_password }}"
3030
force_basic_auth: true
3131
unredirected_headers:
3232
- "Authorization"

etc/kayobe/environments/ci-builder/stackhpc-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ stackhpc_docker_registry_password: !vault |
9494
3664
9595
9696
# Username and password of the overcloud host image repository.
97-
stackhpc_image_repository_username: "{{ stackhpc_docker_registry_username }}"
98-
stackhpc_image_repository_password: "{{ stackhpc_docker_registry_password }}"
97+
stackhpc_release_pulp_username: "{{ stackhpc_docker_registry_username }}"
98+
stackhpc_release_pulp_password: "{{ stackhpc_docker_registry_password }}"

0 commit comments

Comments
 (0)