Skip to content

Commit 1479d90

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 3b420af commit 1479d90

File tree

6 files changed

+50
-47
lines changed

6 files changed

+50
-47
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,11 @@ jobs:
246246
source venvs/kayobe/bin/activate &&
247247
source src/kayobe-config/kayobe-env --environment ci-builder &&
248248
kayobe playbook run \
249-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-upload.yml \
250-
-e image_path=/opt/kayobe/images/overcloud-rocky-9 \
251-
-e host_image_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
249+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
250+
-e artifact_path=/opt/kayobe/images/overcloud-rocky-9 \
251+
-e artifact_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
252+
-e artifact_type="kayobe-images" \
253+
-e file_regex="*.qcow2" \
252254
-e os_distribution="rocky" \
253255
-e os_release="9"
254256
env:
@@ -298,9 +300,11 @@ jobs:
298300
source venvs/kayobe/bin/activate &&
299301
source src/kayobe-config/kayobe-env --environment ci-builder &&
300302
kayobe playbook run \
301-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-upload.yml \
302-
-e image_path=/opt/kayobe/images/overcloud-ubuntu-jammy \
303-
-e host_image_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
303+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-upload.yml \
304+
-e artifact_path=/opt/kayobe/images/overcloud-ubuntu-jammy \
305+
-e artifact_tag=${{ steps.host_image_tag.outputs.host_image_tag }} \
306+
-e artifact_type="kayobe-images" \
307+
-e file_regex="*.qcow2" \
304308
-e os_distribution="ubuntu" \
305309
-e os_release="jammy"
306310
env:

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ jobs:
8383
source venvs/kayobe/bin/activate &&
8484
source src/kayobe-config/kayobe-env --environment ci-builder &&
8585
kayobe playbook run \
86-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-promote.yml \
87-
-e image_path='/opt/kayobe/images/overcloud-rocky-linux-9' \
86+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-promote.yml \
87+
-e artifact_type="kayobe-images" \
8888
-e os_distribution='rocky' \
8989
-e os_release='9'
9090
env:
91-
OVERCLOUD_HOST_IMAGE_TAG: ${{ inputs.image_tag }}
91+
ARTIFACT_TAG: ${{ inputs.image_tag }}
9292
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
9393
if: inputs.rocky9
9494

@@ -97,11 +97,11 @@ jobs:
9797
source venvs/kayobe/bin/activate &&
9898
source src/kayobe-config/kayobe-env --environment ci-builder &&
9999
kayobe playbook run \
100-
src/kayobe-config/etc/kayobe/ansible/pulp-host-image-promote.yml \
101-
-e image_path='/opt/kayobe/images/overcloud-ubuntu-jammy' \
100+
src/kayobe-config/etc/kayobe/ansible/pulp-artifact-promote.yml \
101+
-e artifact_type="kayobe-images" \
102102
-e os_distribution='ubuntu' \
103103
-e os_release='jammy'
104104
env:
105-
OVERCLOUD_HOST_IMAGE_TAG: ${{ inputs.image_tag }}
105+
ARTIFACT_TAG: ${{ inputs.image_tag }}
106106
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
107107
if: inputs.ubuntu-jammy

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

Lines changed: 12 additions & 13 deletions
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

Lines changed: 18 additions & 18 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ stackhpc_docker_registry_password: !vault |
9292
3664
9393
9494
# Username and password of the overcloud host image repository.
95-
stackhpc_image_repository_username: "{{ stackhpc_docker_registry_username }}"
96-
stackhpc_image_repository_password: "{{ stackhpc_docker_registry_password }}"
95+
stackhpc_release_pulp_username: "{{ stackhpc_docker_registry_username }}"
96+
stackhpc_release_pulp_password: "{{ stackhpc_docker_registry_password }}"

0 commit comments

Comments
 (0)