From 5ec350f47e3cc11c5b1c686996b2b890263f9974 Mon Sep 17 00:00:00 2001 From: Karel Simon Date: Thu, 30 May 2024 07:12:08 +0200 Subject: [PATCH] chore: deploy configmaps as a part of pipeline this change will remove the step, when user has to manually create the necessary ConfigMaps needed by VM. They are now deployed and removed by the Pipeline. Added new parameter acceptEula - By setting this parameter to true, user is accepting Eula specified in autounattend.xml file in ConfigMap. If param is set to false, pipeline will exit immediatelly Signed-off-by: Karel Simon --- .../windows10-installer-pipelinerun.yaml | 2 + .../windows11-installer-pipelinerun.yaml | 2 + .../windows2k22-installer-pipelinerun.yaml | 2 + release/pipelines/windows-customize/README.md | 20 +++---- .../windows-customize/windows-customize.yaml | 44 +++++++++++++++ .../pipelines/windows-efi-installer/README.md | 38 +++++++------ .../pipelineruns/pipelineruns.yaml | 4 ++ .../windows-efi-installer.yaml | 56 +++++++++++++++++++ scripts/ansible/variables.yaml | 3 + scripts/deploy-pipelines.sh | 3 - .../windows-customize/README.md | 20 +++---- .../manifests/windows-customize.yaml | 44 +++++++++++++++ .../windows-efi-installer/README.md | 34 +++++------ .../manifests/windows-efi-installer.yaml | 56 +++++++++++++++++++ .../pipelineruns/pipelineruns.yaml | 4 ++ 15 files changed, 277 insertions(+), 55 deletions(-) diff --git a/automation/e2e-pipelines/test-files/windows10-installer-pipelinerun.yaml b/automation/e2e-pipelines/test-files/windows10-installer-pipelinerun.yaml index 3a832504f..036e979ea 100644 --- a/automation/e2e-pipelines/test-files/windows10-installer-pipelinerun.yaml +++ b/automation/e2e-pipelines/test-files/windows10-installer-pipelinerun.yaml @@ -17,5 +17,7 @@ spec: value: win10 - name: isoDVName value: win10 + - name: acceptEula + value: "true" pipelineRef: name: windows-efi-installer diff --git a/automation/e2e-pipelines/test-files/windows11-installer-pipelinerun.yaml b/automation/e2e-pipelines/test-files/windows11-installer-pipelinerun.yaml index 1166432e6..a6bbc911e 100644 --- a/automation/e2e-pipelines/test-files/windows11-installer-pipelinerun.yaml +++ b/automation/e2e-pipelines/test-files/windows11-installer-pipelinerun.yaml @@ -11,5 +11,7 @@ spec: value: http://http-server/disk.img - name: baseDvNamespace value: kubevirt + - name: acceptEula + value: "true" pipelineRef: name: windows-efi-installer diff --git a/automation/e2e-pipelines/test-files/windows2k22-installer-pipelinerun.yaml b/automation/e2e-pipelines/test-files/windows2k22-installer-pipelinerun.yaml index d03e5c123..a34b4cbc9 100644 --- a/automation/e2e-pipelines/test-files/windows2k22-installer-pipelinerun.yaml +++ b/automation/e2e-pipelines/test-files/windows2k22-installer-pipelinerun.yaml @@ -9,6 +9,8 @@ spec: params: - name: winImageDownloadURL value: http://http-server/disk.img + - name: acceptEula + value: "true" - name: preferenceName value: windows.2k22 - name: autounattendConfigMapName diff --git a/release/pipelines/windows-customize/README.md b/release/pipelines/windows-customize/README.md index 1ff0a67a2..21094749b 100644 --- a/release/pipelines/windows-customize/README.md +++ b/release/pipelines/windows-customize/README.md @@ -21,20 +21,20 @@ The provided reference ConfigMap (`windows-sqlserver`) boots Windows 10, 11 or W ## Pipeline Description ``` - copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm + import-unattend-configmaps --- copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps ``` - -1. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters. -2. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume. -3. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. -4. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks). -5. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations). -6. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations). +1. `import-unattend-configmaps` imports ConfigMap with `unattend.xml` needed for automated customization of Windows. +2. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters. +3. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume. +4. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. +5. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks). +6. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations). +7. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations). +8. `delete-imported-configmaps` deletes imported ConfigMaps. ## How to run -Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created. -Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps). +The pipeline uses a ConfigMap containing an `unattend.xml` file for automated customization of Windows. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `unattendXMLConfigMapsURL` parameter and adjust `customizeConfigMapName` parameter with correct the `ConfigMap` name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps). Pipeline runs with resolvers: ```yaml diff --git a/release/pipelines/windows-customize/windows-customize.yaml b/release/pipelines/windows-customize/windows-customize.yaml index 82d2e57cc..c975ef171 100644 --- a/release/pipelines/windows-customize/windows-customize.yaml +++ b/release/pipelines/windows-customize/windows-customize.yaml @@ -25,6 +25,10 @@ spec: reused for customizing Windows 10, 11 or server 2k22. Different OS versions requires different customizeConfigMapName parameter with unattend.xml. params: + - name: unattendXMLConfigMapsURL + description: Allows to specify a download URL to a file with ConfigMaps containing a Windows `unattend.xml` file. These ConfigMaps can be used for automated customization of Windows. Specify the desired ConfigMap name in `customizeConfigMapName` parameter. + type: string + default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-customize/configmaps/windows-customize-configmaps.yaml - name: instanceTypeName type: string description: Name of VirtualMachineClusterInstancetype object @@ -54,7 +58,28 @@ spec: type: string default: win11-customized tasks: + - name: import-unattend-configmaps + params: + - name: SCRIPT + value: oc apply -f $(params.unattendXMLConfigMapsURL) + - name: VERSION + value: latest + taskRef: + resolver: hub + params: + - name: catalog + value: tekton-catalog-tasks + - name: type + value: artifact + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: 0.2.0 - name: copy-vm-root-disk + runAfter: + - import-unattend-configmaps taskRef: resolver: hub params: @@ -187,6 +212,25 @@ spec: value: cleanup-vm - name: version value: v0.20.0 + - name: delete-imported-configmaps + params: + - name: SCRIPT + value: oc delete -f $(params.unattendXMLConfigMapsURL) + - name: VERSION + value: latest + taskRef: + resolver: hub + params: + - name: catalog + value: tekton-catalog-tasks + - name: type + value: artifact + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: 0.2.0 results: - name: baseDvName description: Name of the created base DataVolume diff --git a/release/pipelines/windows-efi-installer/README.md b/release/pipelines/windows-efi-installer/README.md index 865227c33..cc2bf2d57 100644 --- a/release/pipelines/windows-efi-installer/README.md +++ b/release/pipelines/windows-efi-installer/README.md @@ -50,26 +50,28 @@ After the ISO is modified it creates a new VirtualMachine which boots from the m ## Pipeline Description ``` - import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm - | - create-vm-root-disk --- + import-autounattend-configmaps --- import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps + | + create-vm-root-disk --- ``` - -1. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation. -2. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod). -3. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI. -4. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine. -5. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. -6. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes. -7. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used. +1. `import-autounattend-configmaps` imports ConfigMap with `autounattend.xml` needed for automated installation of Windows. +2. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation. +3. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod). +4. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI. +5. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine. +6. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. +7. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes. +8. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used. +9. `delete-imported-configmaps` deletes imported ConfigMaps. ## How to run -Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created. -Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps). Before applying ConfigMap, replace the lines `false<\/AcceptEula>` with `true<\/AcceptEula>`, or run this command: -``` -sed -i "s/false<\/AcceptEula>/true<\/AcceptEula>/g" "configmaps/windows-efi-installer-configmaps.yaml" -``` +Pipeline uses ConfigMaps with `autounattend.xml` file for automated installation of Windows from ISO file. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `autounattendXMLConfigMapsURL` parameter and adjust `autounattendConfigMapName` parameter with the correct ConfigMap name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps). + +> [!IMPORTANT] +> Example PipelineRuns have special parameter acceptEula. By setting this parameter, you are agreeing to the applicable +> Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s). In case you +> set it to false, the Pipeline will exit in first task. Pipeline runs with resolvers: ```yaml @@ -84,6 +86,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false pipelineRef: params: - name: catalog @@ -157,6 +161,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false - name: preferenceName value: windows.2k22 - name: autounattendConfigMapName diff --git a/release/pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml b/release/pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml index 3a1e0ddbb..8d379d67b 100644 --- a/release/pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml +++ b/release/pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml @@ -7,6 +7,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false pipelineRef: resolver: hub params: @@ -74,6 +76,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false - name: preferenceName value: windows.2k22 - name: autounattendConfigMapName diff --git a/release/pipelines/windows-efi-installer/windows-efi-installer.yaml b/release/pipelines/windows-efi-installer/windows-efi-installer.yaml index c0fb0bdf1..1cc0948b8 100644 --- a/release/pipelines/windows-efi-installer/windows-efi-installer.yaml +++ b/release/pipelines/windows-efi-installer/windows-efi-installer.yaml @@ -28,6 +28,13 @@ spec: - description: Download URL to Windows 11 or server 2022 installation ISO (English United States x64 version is needed). You can follow https://www.microsoft.com/en-us/software-download/windows11 or https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022 to get one. name: winImageDownloadURL type: string + - name: acceptEula + description: By setting this parameter, you are agreeing to the applicable Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s). + type: string + - name: autounattendXMLConfigMapsURL + description: Download URL to ConfigMaps with Windows autounattend.xml file. ConfigMap is used for automated installation of Windows from ISO file. Specify the correct ConfigMap name in `autounattendConfigMapName` parameter. + type: string + default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-efi-installer/configmaps/windows-efi-installer-configmaps.yaml - name: instanceTypeName type: string description: Name of VirtualMachineClusterInstancetype object @@ -61,6 +68,34 @@ spec: name: isoDVName type: string tasks: + - name: import-autounattend-configmaps + params: + - name: SCRIPT + value: |- + if [ "$(params.acceptEula)" ]; then + curl $(params.autounattendXMLConfigMapsURL) | \ + sed "s/false<\/AcceptEula>/true<\/AcceptEula>/g" | \ + oc apply -f - + else + echo "Microsoft Eula is not accepted" + echo "Exiting" + exit 1 + fi + - name: VERSION + value: latest + taskRef: + resolver: hub + params: + - name: catalog + value: tekton-catalog-tasks + - name: type + value: artifact + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: 0.2.0 - name: import-win-iso params: - name: manifest @@ -116,6 +151,8 @@ spec: - name: version value: v0.20.0 - name: create-vm-root-disk + runAfter: + - import-autounattend-configmaps taskRef: resolver: hub params: @@ -290,6 +327,25 @@ spec: value: modify-data-object - name: version value: v0.20.0 + - name: delete-imported-configmaps + params: + - name: SCRIPT + value: oc delete -f $(params.autounattendXMLConfigMapsURL) + - name: VERSION + value: latest + taskRef: + resolver: hub + params: + - name: catalog + value: tekton-catalog-tasks + - name: type + value: artifact + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: 0.2.0 results: - description: Name of the created base DataVolume name: baseDvName diff --git a/scripts/ansible/variables.yaml b/scripts/ansible/variables.yaml index a4433fce4..0782a4d1f 100644 --- a/scripts/ansible/variables.yaml +++ b/scripts/ansible/variables.yaml @@ -1,4 +1,7 @@ os_image_namespace: kubevirt-os-images catalog: kubevirt-tekton-tasks +openshift_client_catalog: tekton-catalog-tasks +openshift_client_task_version: 0.2.0 +openshift_client_oc_version: latest catalog_type: artifact pipelines_catalog: kubevirt-tekton-pipelines diff --git a/scripts/deploy-pipelines.sh b/scripts/deploy-pipelines.sh index 235e86c20..9bfe3d4c5 100755 --- a/scripts/deploy-pipelines.sh +++ b/scripts/deploy-pipelines.sh @@ -10,8 +10,5 @@ USE_RESOLVER_IN_MANIFESTS=false make generate-pipelines visit "${REPO_DIR}/release/pipelines" for PIPELINE_NAME in "windows-efi-installer" "windows-customize"; do oc apply -f "${PIPELINE_NAME}/${PIPELINE_NAME}.yaml" - # uncomment accepting eula in autounattend.xml - sed -i "s/false<\/AcceptEula>/true<\/AcceptEula>/g" "${PIPELINE_NAME}/configmaps/${PIPELINE_NAME}-configmaps.yaml" - oc apply -f "${PIPELINE_NAME}/configmaps" done leave diff --git a/templates-pipelines/windows-customize/README.md b/templates-pipelines/windows-customize/README.md index 584d01ee0..37b59d9d3 100644 --- a/templates-pipelines/windows-customize/README.md +++ b/templates-pipelines/windows-customize/README.md @@ -21,20 +21,20 @@ The provided reference ConfigMap (`windows-sqlserver`) boots Windows 10, 11 or W ## Pipeline Description ``` - copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm + import-unattend-configmaps --- copy-vm-root-disk --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps ``` - -1. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters. -2. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume. -3. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. -4. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks). -5. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations). -6. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations). +1. `import-unattend-configmaps` imports ConfigMap with `unattend.xml` needed for automated customization of Windows. +2. `copy-vm-root-disk` Task copies PVC defined in `sourceDiskImageName` and `sourceDiskImageNamespace` parameters. +3. `create-vm` Task creates a VirtualMachine called `windows-customize-*` from the base DataVolume and with the customize ConfigMap attached as a CD-ROM (Pipeline parameter `customizeConfigMapName`). The VirtualMachine has to be created in the same namespace as the source DataVolume. +4. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. +5. `cleanup-vm` deletes the installer VirtualMachine (also in case of failure of the previous Tasks). +6. The output artifact will be the `win*-customized` DataVolume with the customized Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used (depends on the applied customizations). +7. The `windows11-unattend` ConfigMap can be used to boot the VirtualMachine into the Desktop (depends on the applied customizations). +8. `delete-imported-configmaps` deletes imported ConfigMaps. ## How to run -Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created. -Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps). +The pipeline uses a ConfigMap containing an `unattend.xml` file for automated customization of Windows. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `unattendXMLConfigMapsURL` parameter and adjust `customizeConfigMapName` parameter with correct the `ConfigMap` name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-customize/configmaps). Pipeline runs with resolvers: {% for item in pipeline_runs_yaml %} diff --git a/templates-pipelines/windows-customize/manifests/windows-customize.yaml b/templates-pipelines/windows-customize/manifests/windows-customize.yaml index 082e9a5eb..cccbe7eee 100644 --- a/templates-pipelines/windows-customize/manifests/windows-customize.yaml +++ b/templates-pipelines/windows-customize/manifests/windows-customize.yaml @@ -25,6 +25,10 @@ spec: reused for customizing Windows 10, 11 or server 2k22. Different OS versions requires different customizeConfigMapName parameter with unattend.xml. params: + - name: unattendXMLConfigMapsURL + description: Allows to specify a download URL to a file with ConfigMaps containing a Windows `unattend.xml` file. These ConfigMaps can be used for automated customization of Windows. Specify the desired ConfigMap name in `customizeConfigMapName` parameter. + type: string + default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-customize/configmaps/windows-customize-configmaps.yaml - name: instanceTypeName type: string description: Name of VirtualMachineClusterInstancetype object @@ -54,7 +58,28 @@ spec: type: string default: win11-customized tasks: + - name: import-unattend-configmaps + params: + - name: SCRIPT + value: oc apply -f $(params.unattendXMLConfigMapsURL) + - name: VERSION + value: {{ openshift_client_oc_version }} + taskRef: + resolver: hub + params: + - name: catalog + value: {{ openshift_client_catalog }} + - name: type + value: {{ catalog_type }} + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: {{ openshift_client_task_version }} - name: copy-vm-root-disk + runAfter: + - import-unattend-configmaps taskRef: {% if use_resolver_in_manifests %} resolver: hub @@ -207,6 +232,25 @@ spec: kind: Task name: cleanup-vm {% endif %} + - name: delete-imported-configmaps + params: + - name: SCRIPT + value: oc delete -f $(params.unattendXMLConfigMapsURL) + - name: VERSION + value: {{ openshift_client_oc_version }} + taskRef: + resolver: hub + params: + - name: catalog + value: {{ openshift_client_catalog }} + - name: type + value: {{ catalog_type }} + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: {{ openshift_client_task_version }} results: - name: baseDvName description: Name of the created base DataVolume diff --git a/templates-pipelines/windows-efi-installer/README.md b/templates-pipelines/windows-efi-installer/README.md index 7eafbd979..0ec7a1c7d 100644 --- a/templates-pipelines/windows-efi-installer/README.md +++ b/templates-pipelines/windows-efi-installer/README.md @@ -50,26 +50,28 @@ After the ISO is modified it creates a new VirtualMachine which boots from the m ## Pipeline Description ``` - import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm - | - create-vm-root-disk --- + import-autounattend-configmaps --- import-win-iso --- modify-windows-iso-file --- create-vm --- wait-for-vmi-status --- cleanup-vm --- delete-imported-configmaps + | + create-vm-root-disk --- ``` - -1. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation. -2. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod). -3. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI. -4. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine. -5. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. -6. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes. -7. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used. +1. `import-autounattend-configmaps` imports ConfigMap with `autounattend.xml` needed for automated installation of Windows. +2. `create-vm-root-disk` creates empty DataVolume which is used for Windows installation. +3. `import-win-iso` creates new DataVolume with Windows ISO file with name defined in `isoDVName` parameter. The DataVolume needs to be in the same namespace as the PipelineRun (because the PVC is mounted into the PipelineRun pod). +4. `modify-windows-iso-file` extracts imported ISO file, replaces prompt bootloader (which is used as a default one when EFI is used) with no-prompt bootloader, pack the updated files back to new ISO, convert the ISO and replaces original ISO with updated one.Replacement of bootloader is needed to be able to automate installation of Windows versions which require EFI. +5. `create-vm` Task creates a VirtualMachine. A DataVolume with the Windows source ISO will be attached as CD-ROM and a second empty DataVolume will be used as installation destination. A third DataVolume with the virtio-win ISO will also be attached (Pipeline parameter `virtioContainerDiskName`). The VirtualMachine has to be created in the same namespace as the DataVolume with the ISO file. In case you would like to run the VirtualMachine in a different namespace, both Datavolumes have to be copied to the same namespace as the VirtualMachine. +6. `wait-for-vmi-status` Task waits until the VirtualMachine shuts down. +7. `cleanup-vm` deletes the installer VirtualMachine and all of its DataVolumes. +8. The output artifact will be the `baseDvName`/`baseDvNamespace` DataVolume with the basic Windows installation. It will boot into the Windows OOBE and needs to be setup further before it can be used. +9. `delete-imported-configmaps` deletes imported ConfigMaps. ## How to run -Before you create PipelineRuns, you must create ConfigMaps with an autounattend.xml in the same namespace in which the VirtualMachine will be created. -Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps). Before applying ConfigMap, replace the lines `false<\/AcceptEula>` with `true<\/AcceptEula>`, or run this command: -``` -sed -i "s/false<\/AcceptEula>/true<\/AcceptEula>/g" "configmaps/windows-efi-installer-configmaps.yaml" -``` +Pipeline uses ConfigMaps with `autounattend.xml` file for automated installation of Windows from ISO file. Example ConfigMaps are deployed within the Pipeline. In case you would like to use a different ConfigMap, specify a different URL in the `autounattendXMLConfigMapsURL` parameter and adjust `autounattendConfigMapName` parameter with the correct ConfigMap name. Examples of ConfigMaps can be found [here](https://github.com/kubevirt/kubevirt-tekton-tasks/tree/main/release/pipelines/windows-efi-installer/configmaps). + +> [!IMPORTANT] +> Example PipelineRuns have special parameter acceptEula. By setting this parameter, you are agreeing to the applicable +> Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s). In case you +> set it to false, the Pipeline will exit in first task. Pipeline runs with resolvers: {% for item in pipeline_runs_yaml %} diff --git a/templates-pipelines/windows-efi-installer/manifests/windows-efi-installer.yaml b/templates-pipelines/windows-efi-installer/manifests/windows-efi-installer.yaml index 4ab8ca980..491551747 100644 --- a/templates-pipelines/windows-efi-installer/manifests/windows-efi-installer.yaml +++ b/templates-pipelines/windows-efi-installer/manifests/windows-efi-installer.yaml @@ -28,6 +28,13 @@ spec: - description: Download URL to Windows 11 or server 2022 installation ISO (English United States x64 version is needed). You can follow https://www.microsoft.com/en-us/software-download/windows11 or https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022 to get one. name: winImageDownloadURL type: string + - name: acceptEula + description: By setting this parameter, you are agreeing to the applicable Microsoft end user license agreement(s) for each deployment or installation for the Microsoft product(s). + type: string + - name: autounattendXMLConfigMapsURL + description: Download URL to ConfigMaps with Windows autounattend.xml file. ConfigMap is used for automated installation of Windows from ISO file. Specify the correct ConfigMap name in `autounattendConfigMapName` parameter. + type: string + default: https://raw.githubusercontent.com/kubevirt/kubevirt-tekton-tasks/main/release/pipelines/windows-efi-installer/configmaps/windows-efi-installer-configmaps.yaml - name: instanceTypeName type: string description: Name of VirtualMachineClusterInstancetype object @@ -61,6 +68,34 @@ spec: name: isoDVName type: string tasks: + - name: import-autounattend-configmaps + params: + - name: SCRIPT + value: |- + if [ "$(params.acceptEula)" ]; then + curl $(params.autounattendXMLConfigMapsURL) | \ + sed "s/false<\/AcceptEula>/true<\/AcceptEula>/g" | \ + oc apply -f - + else + echo "Microsoft Eula is not accepted" + echo "Exiting" + exit 1 + fi + - name: VERSION + value: {{ openshift_client_oc_version }} + taskRef: + resolver: hub + params: + - name: catalog + value: {{ openshift_client_catalog }} + - name: type + value: {{ catalog_type }} + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: {{ openshift_client_task_version }} - name: import-win-iso params: - name: manifest @@ -126,6 +161,8 @@ spec: name: modify-windows-iso-file {% endif %} - name: create-vm-root-disk + runAfter: + - import-autounattend-configmaps taskRef: {% if use_resolver_in_manifests %} resolver: hub @@ -325,6 +362,25 @@ spec: kind: Task name: modify-data-object {% endif %} + - name: delete-imported-configmaps + params: + - name: SCRIPT + value: oc delete -f $(params.autounattendXMLConfigMapsURL) + - name: VERSION + value: {{ openshift_client_oc_version }} + taskRef: + resolver: hub + params: + - name: catalog + value: {{ openshift_client_catalog }} + - name: type + value: {{ catalog_type }} + - name: kind + value: task + - name: name + value: openshift-client + - name: version + value: {{ openshift_client_task_version }} results: - description: Name of the created base DataVolume name: baseDvName diff --git a/templates-pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml b/templates-pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml index 16ec0c44d..9659af279 100644 --- a/templates-pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml +++ b/templates-pipelines/windows-efi-installer/pipelineruns/pipelineruns.yaml @@ -7,6 +7,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false pipelineRef: resolver: hub params: @@ -74,6 +76,8 @@ spec: params: - name: winImageDownloadURL value: ${WIN_IMAGE_DOWNLOAD_URL} + - name: acceptEula + value: false - name: preferenceName value: windows.2k22 - name: autounattendConfigMapName