Skip to content

Commit 48df9a3

Browse files
authored
MGMT-23799: Use openshift versions for osImages ISOs (#213)
* Use openshift versions for osImages ISOs Previously the ISO version set in the osImages list for AgentServiceConfig was completely separate from the versions the user provided for ClusterImageSets. These need to match otherwise cluster creation could fail for a mismatch. This commit adds logic to fetch the ISO for each listed openshift version usin `oc` commands rather than keeping a separate list of http endpoints. This ensures that every ClusterImageSet will always have a matching ISO configured. Resolves https://redhat.atlassian.net/browse/MGMT-23799 * use blkid instead of isoinfo to avoid requiring epel on the LZ host * Move download content after control binaries so the oc cli is available * Extract just the iso file rather than an entire directory This wasn't working at all, the directory ended up empty, but it's better to just get the file we need anyway * Move blkid call to where the value is needed and always remove temp dirs
1 parent 4177337 commit 48df9a3

11 files changed

Lines changed: 74 additions & 98 deletions

File tree

defaults/content_images.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/CONFIGURATION_REFERENCE.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Configuration is split across multiple files for better organization and maintai
1515
| `defaults/platforms.yaml` | Available OpenShift versions |
1616
| `defaults/deployment.yaml` | Deployment defaults (storage plugin, disconnected mode, etc.) |
1717
| `defaults/control_binaries.yaml` | URLs and checksums for required binaries (oc, helm, etc.) |
18-
| `defaults/content_images.yaml` | RHCOS images and ISOs configuration |
1918
| `defaults/catalogs.yaml` | Operator catalog source name mappings |
2019
| `defaults/mirror_registry.yaml` | Quay hostname and CA path defaults |
2120
| `defaults/k8s.yaml` | Kubernetes retry settings for k8s module calls |
@@ -1133,7 +1132,6 @@ Core operators are defined in `defaults/operators.yaml`. Plugin operators are de
11331132

11341133
Content configuration is stored in the `defaults/` directory:
11351134
- `defaults/control_binaries.yaml` - Binary downloads (oc, helm, mirror-registry, oc-mirror)
1136-
- `defaults/content_images.yaml` - RHCOS ISO images
11371135

11381136
### Control Binaries
11391137

@@ -1173,31 +1171,14 @@ control_binaries:
11731171
- URLs should point to official Red Hat sources
11741172
- Update version numbers as needed
11751173

1176-
### Content Images
1174+
### RHCOS ISOs
11771175

1178-
#### `content_images`
1176+
RHCOS ISOs are automatically extracted from OpenShift release images during the prepare phase. For each version defined in `defaults/platforms.yaml`, the system:
11791177

1180-
**Description**: URLs and checksums for RHCOS images.
1181-
1182-
**Location**: `defaults/content_images.yaml`
1183-
1184-
**Type**: Dictionary
1185-
1186-
**Example**:
1187-
```yaml
1188-
content_images:
1189-
isos:
1190-
- url: "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.19/4.19.10/rhcos-4.19.10-x86_64-live-iso.x86_64.iso"
1191-
checksum: "sha256:7a47d0c7a9bf5edb143d52809e793af2d74731567b95d91c6225171a1c49b5ab"
1192-
```
1193-
1194-
**Fields**:
1195-
- `isos`: List of ISO images (used for cluster deployment)
1196-
1197-
**Notes**:
1198-
- Version should match OCP version
1199-
- Checksums are verified after download
1200-
- Multiple entries allowed (for different architectures)
1178+
1. Queries the release image for the `machine-os-images` component
1179+
2. Extracts the ISO from the machine-os-images container
1180+
3. Determines the ISO volume ID using `blkid`
1181+
4. Stores the ISO at `/var/www/html/rhcos-<version>-x86_64-live-iso.x86_64.iso`
12011182

12021183
## Complete Example
12031184

docs/DEPLOYMENT_GUIDE.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ Configuration is split across multiple files for better organization:
149149
- `defaults/deployment.yaml` - Deployment behavior defaults
150150
- `defaults/k8s.yaml` - Kubernetes resource defaults
151151
- `defaults/control_binaries.yaml` - Binary URLs and checksums (oc, helm, etc.)
152-
- `defaults/content_images.yaml` - RHCOS images and ISOs
153152
- `defaults/catalogs.yaml` - Operator catalog source name mappings
154153
- `defaults/mirror_registry.yaml` - Quay hostname and CA path defaults
155154
- `defaults/quay_operator.yaml` - Quay feature flags and backend storage defaults
@@ -447,14 +446,6 @@ control_binaries:
447446
checksum: "sha256:..."
448447
```
449448

450-
**`defaults/content_images.yaml`** - RHCOS ISO images:
451-
```yaml
452-
content_images:
453-
isos:
454-
- url: "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.19/4.19.10/rhcos-4.19.10-x86_64-live-iso.x86_64.iso"
455-
checksum: "sha256:..."
456-
```
457-
458449
## Detailed Configuration Reference
459450

460451
### Network Configuration

operators/multicluster-engine/tasks.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,14 @@
300300
until: r_configmap_assisted_service is success
301301

302302
- name: Create AgentServiceConfig for disconnected environment
303+
vars:
304+
_osimages: |
305+
{% for v in openshift_versions %}
306+
- cpuArchitecture: x86_64
307+
openshiftVersion: "{{ v.version }}"
308+
url: "http://{{ quayHostname }}/rhcos-{{ v.version }}-x86_64-live-iso.x86_64.iso"
309+
version: "{{ lookup('pipe', 'blkid -s LABEL -o value /var/www/html/rhcos-' + v.version + '-x86_64-live-iso.x86_64.iso') | trim }}"
310+
{% endfor %}
303311
kubernetes.core.k8s:
304312
state: present
305313
definition:
@@ -325,11 +333,7 @@
325333
resources:
326334
requests:
327335
storage: 40Gi
328-
osImages:
329-
- cpuArchitecture: x86_64
330-
openshiftVersion: "4.20"
331-
url: "http://{{ quayHostname }}/rhcos-4.20.0-x86_64-live-iso.x86_64.iso"
332-
version: 9.6.20251023-0
336+
osImages: "{{ _osimages | from_yaml }}"
333337
register: r_agentserviceconfig
334338
retries: "{{ k8s_retries }}"
335339
delay: "{{ k8s_delay }}"

playbooks/01-prepare.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@
3131
tags: always
3232
tags: always
3333

34-
- name: Download content
35-
ansible.builtin.include_tasks:
36-
file: tasks/download_content.yaml
37-
apply:
38-
tags: download-content
39-
tags: download-content
40-
4134
- name: Download control binaries
4235
ansible.builtin.include_tasks:
4336
file: tasks/download_control_binaries.yaml
4437
apply:
4538
tags: download-control-binaries
4639
tags: download-control-binaries
40+
41+
- name: Download content
42+
ansible.builtin.include_tasks:
43+
file: tasks/download_content.yaml
44+
apply:
45+
tags: download-content
46+
tags: download-content

playbooks/common/load-vars.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
- name: Include common configuration
1616
ansible.builtin.include_vars: "../../defaults/{{ config_file }}"
1717
loop:
18-
- content_images.yaml
1918
- control_binaries.yaml
2019
- operators.yaml
2120
- platforms.yaml
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
---
2-
- name: Download RHCOS live ISOs
3-
become: true
4-
ansible.builtin.get_url:
5-
url: "{{ iso_item.url }}"
6-
dest: "/var/www/html/{{ (iso_item.url | ansible.builtin.split('/'))[-1] }}"
7-
checksum: "{{ iso_item.checksum }}"
8-
loop: "{{ content_images.isos }}"
2+
- name: Extract RHCOS ISOs from OpenShift release images
3+
ansible.builtin.include_tasks:
4+
file: download_content_single_version.yaml
5+
loop: "{{ openshift_versions }}"
96
loop_control:
10-
loop_var: iso_item
7+
loop_var: version_item
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
- name: Check if ISO already exists for {{ version_item.version }}
3+
ansible.builtin.stat:
4+
path: "/var/www/html/rhcos-{{ version_item.version }}-x86_64-live-iso.x86_64.iso"
5+
register: iso_exists
6+
7+
- name: Extract ISO for {{ version_item.version }}
8+
when: not iso_exists.stat.exists
9+
block:
10+
- name: Get machine-os-images digest for {{ version_item.version }}
11+
ansible.builtin.command:
12+
cmd: >
13+
oc adm release info
14+
--image-for=machine-os-images
15+
quay.io/openshift-release-dev/ocp-release:{{ version_item.version }}-x86_64
16+
register: machine_os_image
17+
changed_when: false
18+
19+
- name: Create temporary extraction directory
20+
ansible.builtin.tempfile:
21+
state: directory
22+
prefix: "rhcos-extract-{{ version_item.version }}-"
23+
register: temp_extract_dir
24+
25+
- name: Extract ISO from machine-os-images container
26+
ansible.builtin.command:
27+
cmd: >
28+
oc image extract
29+
--registry-config={{ pullSecretPath }}
30+
{{ machine_os_image.stdout }}
31+
--path /coreos/coreos-x86_64.iso:{{ temp_extract_dir.path }}/
32+
changed_when: true
33+
34+
- name: Move ISO to final location with version-specific name
35+
become: true
36+
ansible.builtin.copy:
37+
src: "{{ temp_extract_dir.path }}/coreos-x86_64.iso"
38+
dest: "/var/www/html/rhcos-{{ version_item.version }}-x86_64-live-iso.x86_64.iso"
39+
remote_src: true
40+
mode: '0644'
41+
42+
always:
43+
- name: Clean up temporary extraction directory
44+
ansible.builtin.file:
45+
path: "{{ temp_extract_dir.path }}"
46+
state: absent
47+
when: temp_extract_dir is defined

playbooks/tasks/template_validation/setup.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- name: Include common configuration
99
ansible.builtin.include_vars: "../../defaults/{{ config_file }}"
1010
loop:
11-
- content_images.yaml
1211
- control_binaries.yaml
1312
- operators.yaml
1413
- platforms.yaml

playbooks/validation/tasks/defaults_schema_validation.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
criteria: "{{ lookup('ansible.builtin.file', '../../schemas/catalogs.yaml') | from_yaml | combine(schema_definitions, recursive=True) | to_json }}"
1515
engine: ansible.utils.jsonschema
1616

17-
- name: validate defaults/content_images.yaml schema
18-
ansible.utils.validate:
19-
data: "{{ lookup('ansible.builtin.file', '../../defaults/content_images.yaml') | from_yaml | to_json }}"
20-
criteria: "{{ lookup('ansible.builtin.file', '../../schemas/content_images.yaml') | from_yaml | combine(schema_definitions, recursive=True) | to_json }}"
21-
engine: ansible.utils.jsonschema
22-
2317
- name: validate defaults/control_binaries.yaml schema
2418
ansible.utils.validate:
2519
data: "{{ lookup('ansible.builtin.file', '../../defaults/control_binaries.yaml') | from_yaml | to_json }}"

0 commit comments

Comments
 (0)