From 282509e5ea3147e8aaa00b11259088d7cca154ac Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 11 Nov 2024 23:14:11 +0000 Subject: [PATCH 1/2] ci: add ova-poi-harness job to build and deploy minimal OVA --- .gitlab-ci.yml | 26 ++++++++++++++++++++--- examples/ova/minimal_ks.yaml | 7 +++++++ examples/ova/minimal_ova.yaml | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 examples/ova/minimal_ova.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac923cb..c0cb6e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,13 +17,13 @@ build-container: - docker push ${POI_REGISTRY}/${POI_IMAGE_NAME} - docker system prune -f -cayman_poi: +.cayman_poi: stage: build needs: [] script: - ./ci/gitlab/submodule_ci.py --private-token=$CAYMAN_POI_CICD_API_TOKEN --project-id core-build/cayman_photon-os-installer --branch test/poi-submodule/$CI_COMMIT_SHORT_SHA --parent-branch vmware-master --submodule-path poi/src --submodule-sha $CI_COMMIT_SHA -pytest: +.pytest: stage: test needs: - build-container @@ -36,6 +36,26 @@ pytest: - cd tests/ - sudo chown -R $(id -u -n):$(id -g -n) . +ova-poi-harness: + variables: + VM_NAME: poi-harness-${CI_COMMIT_SHORT_SHA} + stage: test + needs: + - build-container + script: + - docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME} + - docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME} + - cd examples/ova + - docker run --rm --privileged -v/dev:/dev -v$(pwd):/workdir ${POI_IMAGE_NAME} create-image --repo-paths= -c minimal_ks.yaml -v 5.0 + - docker run --rm -v$(pwd):/workdir -w/workdir ${POI_IMAGE_NAME} create-ova --ovf --mf --vmdk --installer-config minimal_ks.yaml --ova-config minimal_ova.yaml + # clone the harness code + - git clone --depth=1 https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git + - pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf *.ovf --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config minimal_ks.yaml --ova_config minimal_ova.yaml + after_script: + # change ownerships for cleanup + - cd examples/ova + - sudo chown -R $(id -u -n):$(id -g -n) . + iso-poi-harness: variables: ISO_OVF: photon5-iso-boot-${CI_COMMIT_SHORT_SHA}.ovf @@ -53,7 +73,7 @@ iso-poi-harness: # base64 encode the ks file, must have no new lines (-w0) - docker run --rm -v$(pwd):/workdir ${POI_IMAGE_NAME} ova-compose -i iso_ova.yaml -o ${ISO_OVF} -m --param ksdata64=$(base64 -w0 < minimal_ks.yaml) # clone the harness code - - git clone https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git + - git clone --depth=1 https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git # POI harness will deploy OVF on a VC and run tests - pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf ${ISO_OVF} --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config minimal_ks.yaml --ova_config iso_ova.yaml after_script: diff --git a/examples/ova/minimal_ks.yaml b/examples/ova/minimal_ks.yaml index 8267c90..80c2353 100644 --- a/examples/ova/minimal_ks.yaml +++ b/examples/ova/minimal_ks.yaml @@ -22,6 +22,13 @@ partitions: - sizepercent: 5 filesystem: swap +repos: + photon: + name: "Photon 5.0" + baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch + enabled: 1 + gpgcheck: 0 + packagelist_file: packages_minimal.json additional_packages: diff --git a/examples/ova/minimal_ova.yaml b/examples/ova/minimal_ova.yaml new file mode 100644 index 0000000..6f2a573 --- /dev/null +++ b/examples/ova/minimal_ova.yaml @@ -0,0 +1,39 @@ +system: + name: minimal + type: vmx-14 vmx-20 vmx-21 + os_vmw: vmwarePhoton64Guest + firmware: efi + secure_boot: false + +networks: + vm_network: + name: "VM Network" + description: "The VM Network network" + +hardware: + cpus: 2 + memory: 2048 + sata1: + type: sata_controller + scsi1: + type: scsi_controller + cdrom1: + type: cd_drive + parent: sata1 + Harddisk 1: + type: hard_disk + parent: scsi1 + raw_image: !param rootdisk=minimal.img + units: byte + usb2: + type: usb_controller + usb3: + type: usb3_controller + ethernet1: + type: ethernet + subtype: VmxNet3 + network: vm_network + videocard1: + type: video_card + vmci1: + type: vmci From 28081d6463dd19a6ed411eb1c9bd939aa8c53c73 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Tue, 12 Nov 2024 01:44:44 +0000 Subject: [PATCH 2/2] add LVM build and deploy test --- .gitlab-ci.yml | 21 +++++++++++++++------ examples/ova/minimal_ks.yaml | 4 +++- examples/ova/minimal_lvm_ks.yaml | 11 ++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c0cb6e5..601a214 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,13 +17,13 @@ build-container: - docker push ${POI_REGISTRY}/${POI_IMAGE_NAME} - docker system prune -f -.cayman_poi: +cayman_poi: stage: build needs: [] script: - ./ci/gitlab/submodule_ci.py --private-token=$CAYMAN_POI_CICD_API_TOKEN --project-id core-build/cayman_photon-os-installer --branch test/poi-submodule/$CI_COMMIT_SHORT_SHA --parent-branch vmware-master --submodule-path poi/src --submodule-sha $CI_COMMIT_SHA -.pytest: +pytest: stage: test needs: - build-container @@ -38,19 +38,28 @@ build-container: ova-poi-harness: variables: - VM_NAME: poi-harness-${CI_COMMIT_SHORT_SHA} + VM_NAME_BASE: ova-poi-harness-${CI_COMMIT_SHORT_SHA} stage: test needs: - build-container + parallel: + matrix: + - NAME: + - minimal + - minimal_lvm script: + - VM_NAME=${VM_NAME_BASE}-${NAME} + - KS_FILE=${NAME}_ks.yaml + - docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME} - docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME} + - cd examples/ova - - docker run --rm --privileged -v/dev:/dev -v$(pwd):/workdir ${POI_IMAGE_NAME} create-image --repo-paths= -c minimal_ks.yaml -v 5.0 - - docker run --rm -v$(pwd):/workdir -w/workdir ${POI_IMAGE_NAME} create-ova --ovf --mf --vmdk --installer-config minimal_ks.yaml --ova-config minimal_ova.yaml + - docker run --rm --privileged -v/dev:/dev -v$(pwd):/workdir ${POI_IMAGE_NAME} create-image --repo-paths= -c ${KS_FILE} -v 5.0 + - docker run --rm -v$(pwd):/workdir -w/workdir ${POI_IMAGE_NAME} create-ova --ovf --mf --vmdk --installer-config ${KS_FILE} --ova-config minimal_ova.yaml # clone the harness code - git clone --depth=1 https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git - - pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf *.ovf --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config minimal_ks.yaml --ova_config minimal_ova.yaml + - pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf *.ovf --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config ${KS_FILE} --ova_config minimal_ova.yaml after_script: # change ownerships for cleanup - cd examples/ova diff --git a/examples/ova/minimal_ks.yaml b/examples/ova/minimal_ks.yaml index 80c2353..4118060 100644 --- a/examples/ova/minimal_ks.yaml +++ b/examples/ova/minimal_ks.yaml @@ -34,7 +34,9 @@ packagelist_file: packages_minimal.json additional_packages: - vim -public_key: +postinstall: + # allow ssh root login + - sed -i "s/\(^PermitRootLogin\)[ ]*no$/\1 yes/g" /etc/ssh/sshd_config linux_flavor: linux diff --git a/examples/ova/minimal_lvm_ks.yaml b/examples/ova/minimal_lvm_ks.yaml index 6651026..b44f158 100644 --- a/examples/ova/minimal_lvm_ks.yaml +++ b/examples/ova/minimal_lvm_ks.yaml @@ -20,12 +20,21 @@ partitions: vg_name: vg_root_0 lv_name: lv_root_0 +repos: + photon: + name: "Photon 5.0" + baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch + enabled: 1 + gpgcheck: 0 + packagelist_file: packages_minimal.json additional_packages: - vim -public_key: +postinstall: + # allow ssh root login + - sed -i "s/\(^PermitRootLogin\)[ ]*no$/\1 yes/g" /etc/ssh/sshd_config linux_flavor: linux