diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index f6bbeb70e..0b44f1e7a 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -86,6 +86,7 @@ SSH_KEY=${SSH_DATA_DIR}/id_rsa SSH_KEY_PUB=$(cat "${SSH_KEY}".pub) # kernel-rt package name (differs in CS8) + KERNEL_RT_PKG="kernel-rt" case "${ID}-${VERSION_ID}" in @@ -375,6 +376,89 @@ greenprint "๐Ÿงฝ Clean up container blueprint and compose" sudo composer-cli compose delete "${COMPOSE_ID}" > /dev/null sudo composer-cli blueprints delete container > /dev/null +############################################################ +## +## Setup Ignition +## +############################################################ + +# TODO(runcom): change this to butane to check that too +HTTPD_PATH="/var/www/html" +IGN_PATH="${HTTPD_PATH}/ignition" +sudo mkdir -p ${IGN_PATH} +IGN_CONFIG_PATH="${IGN_PATH}/config.ign" +sudo tee "$IGN_CONFIG_PATH" > /dev/null << EOF +{ + "ignition": { + "config": { + "merge": [ + { + "source": "http://192.168.100.1/ignition/sample.ign" + } + ] + }, + "timeouts": { + "httpTotal": 30 + }, + "version": "3.3.0" + }, + "passwd": { + "users": [ + { + "groups": [ + "wheel" + ], + "name": "core", + "passwordHash": "\$6\$GRmb7S0p8vsYmXzH\$o0E020S.9JQGaHkszoog4ha4AQVs3sk8q0DvLjSMxoxHBKnB2FBXGQ/OkwZQfW/76ktHd0NX5nls2LPxPuUdl.", + "sshAuthorizedKeys": [ + "${SSH_KEY_PUB}" + ] + } + ] + } +} +EOF + +IGN_CONFIG_SAMPLE_PATH="${IGN_PATH}/sample.ign" +sudo tee "$IGN_CONFIG_SAMPLE_PATH" > /dev/null << EOF +{ + "ignition": { + "version": "3.3.0" + }, + "storage": { + "files": [ + { + "path": "/usr/local/bin/startup.sh", + "contents": { + "compression": "", + "source": "data:;base64,IyEvYmluL2Jhc2gKZWNobyAiSGVsbG8sIFdvcmxkISIK" + }, + "mode": 493 + } + ] + }, + "systemd": { + "units": [ + { + "contents": "[Unit]\nDescription=A hello world unit!\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/local/bin/startup.sh\n[Install]\nWantedBy=multi-user.target\n", + "enabled": true, + "name": "hello.service" + }, + { + "dropins": [ + { + "contents": "[Service]\nEnvironment=LOG_LEVEL=trace\n", + "name": "log_trace.conf" + } + ], + "name": "fdo-client-linuxapp.service" + } + ] + } +} +EOF +sudo chmod -R +r ${HTTPD_PATH}/ignition/* + ############################################################ ## ## Build edge-raw-image @@ -390,6 +474,20 @@ modules = [] groups = [] EOF +IGNITION=1 +HAS_IGNITION="false" +if [[ "${ID}-${VERSION_ID}" = "rhel-9.2" || "${ID}-${VERSION_ID}" = "centos-9" ]]; then + IGNITION=0 + HAS_IGNITION="true" +fi + +if [[ ${IGNITION} -eq 0 ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[customizations.ignition.firstboot] +url = "http://192.168.100.1/ignition/config.ign" +EOF +fi + # User in raw image blueprint is not for RHEL 9.1 and 8.7 # Workaround for RHEL 9.1 and 8.7 nightly test if [[ "$USER_IN_RAW" == "true" ]]; then @@ -497,9 +595,30 @@ ansible_become_pass=${EDGE_USER_PASSWORD} EOF # Test IoT/Edge OS - sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result + if [[ ${IGNITION} -eq 0 ]]; then + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF +[ostree_guest] +${BIOS_GUEST_ADDRESS} + +[ostree_guest:vars] +ansible_python_interpreter=/usr/bin/python3 +ansible_user=core +ansible_private_key_file=${SSH_KEY} +ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +ansible_become=yes +ansible_become_method=sudo +ansible_become_pass=${EDGE_USER_PASSWORD} +EOF + + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result + fi + # Clean up BIOS VM greenprint "๐Ÿงน Clean up BIOS VM" if [[ $(sudo virsh domstate "${IMAGE_KEY}-bios") == "running" ]]; then @@ -573,9 +692,32 @@ ansible_become_pass=${EDGE_USER_PASSWORD} EOF # Test IoT/Edge OS -sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 +sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result +# test with ignition user + +if [[ ${IGNITION} -eq 0 ]]; then + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF +[ostree_guest] +${UEFI_GUEST_ADDRESS} + +[ostree_guest:vars] +ansible_python_interpreter=/usr/bin/python3 +ansible_user=core +ansible_private_key_file=${SSH_KEY} +ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +ansible_become=yes +ansible_become_method=sudo +ansible_become_pass=${EDGE_USER_PASSWORD} +EOF + + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result +fi + ################################################################## ## ## Upgrade and test edge vm with edge-raw-image (UEFI) @@ -711,6 +853,27 @@ done # Check ostree upgrade result check_result +if [[ ${IGNITION} -eq 0 ]]; then + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF + [ostree_guest] + ${UEFI_GUEST_ADDRESS} + + [ostree_guest:vars] + ansible_python_interpreter=/usr/bin/python3 + ansible_user=core + ansible_private_key_file=${SSH_KEY} + ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + ansible_become=yes + ansible_become_method=sudo + ansible_become_pass=${EDGE_USER_PASSWORD} +EOF + + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e edge_type=edge-raw-image -e ostree_commit="${UPGRADE_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result +fi + # Add instance IP address into /etc/ansible/hosts sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF [ostree_guest] diff --git a/test/cases/ostree-simplified-installer.sh b/test/cases/ostree-simplified-installer.sh index 8565c80fa..12663ee72 100755 --- a/test/cases/ostree-simplified-installer.sh +++ b/test/cases/ostree-simplified-installer.sh @@ -795,7 +795,6 @@ fi ################################################################## # TODO(runcom): change this to butane to check that too -# also, write the very same test for ostree-raw-image IGN_PATH="${HTTPD_PATH}/ignition" sudo mkdir -p ${IGN_PATH} IGN_CONFIG_PATH="${IGN_PATH}/config.ign" @@ -881,140 +880,6 @@ sudo chmod -R +r ${HTTPD_PATH}/ignition/* ######################################################################## if [[ "${ID}-${VERSION_ID}" = "rhel-9.2" || "${ID}-${VERSION_ID}" = "centos-9" ]]; then -# tee "$BLUEPRINT_FILE" > /dev/null < /dev/null -# ISO_FILENAME="${COMPOSE_ID}-${INSTALLER_FILENAME}" -# sudo cp "${ISO_FILENAME}" /var/lib/libvirt/images - -# # Clean compose and blueprints. -# greenprint "๐Ÿงน Clean up simplified_iso_with_ignition_embedded_url blueprint and compose" -# sudo composer-cli compose delete "${COMPOSE_ID}" > /dev/null -# sudo composer-cli blueprints delete simplified_iso_with_ignition_embedded_url > /dev/null - -# # Ensure SELinux is happy with our new images. -# greenprint "๐Ÿ‘ฟ Running restorecon on image directory" -# sudo restorecon -Rv /var/lib/libvirt/images/ - -# # Create qcow2 file for virt install. -# greenprint "๐Ÿ–ฅ Create qcow2 file for virt install" -# sudo qemu-img create -f qcow2 "${LIBVIRT_IMAGE_PATH}" 20G - -# greenprint "๐Ÿ’ฟ Install ostree image via installer(ISO) on UEFI VM" -# sudo virt-install --name="${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url"\ -# --disk path="${LIBVIRT_IMAGE_PATH}",format=qcow2 \ -# --ram "${MEMORY}" \ -# --vcpus 2 \ -# --network network=integration,mac=34:49:22:B0:83:33 \ -# --os-type linux \ -# --os-variant ${OS_VARIANT} \ -# --cdrom "/var/lib/libvirt/images/${ISO_FILENAME}" \ -# --boot "$BOOT_ARGS" \ -# --tpm backend.type=emulator,backend.version=2.0,model=tpm-crb \ -# --nographics \ -# --noautoconsole \ -# --wait=15 \ -# --noreboot - -# # Installation can get stuck, destroying VM helps -# # See https://github.com/osbuild/osbuild-composer/issues/2413 -# if [[ $(sudo virsh domstate "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url") == "running" ]]; then -# sudo virsh destroy "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url" -# fi - -# # Start VM. -# greenprint "๐Ÿ’ป Start UEFI VM" -# sudo virsh start "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url" - -# # Check for ssh ready to go. -# greenprint "๐Ÿ›ƒ Checking for SSH is ready to go" -# for LOOP_COUNTER in $(seq 0 30); do -# RESULTS="$(wait_for_ssh_up $IGNITION_GUEST_ADDRESS)" -# if [[ $RESULTS == 1 ]]; then -# echo "SSH is ready now! ๐Ÿฅณ" -# break -# fi -# sleep 10 -# done - -# # Check image installation result -# check_result - -# greenprint "๐Ÿ•น Get ostree install commit value" -# INSTALL_HASH=$(curl "${PROD_REPO_URL}/refs/heads/${OSTREE_REF}") - -# if [[ ${IGNITION} -eq 0 ]]; then -# # Add instance IP address into /etc/ansible/hosts -# sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF -# [ostree_guest] -# ${IGNITION_GUEST_ADDRESS} - -# [ostree_guest:vars] -# ansible_python_interpreter=/usr/bin/python3 -# ansible_user=core -# ansible_private_key_file=${SSH_KEY} -# ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -# ansible_become=yes -# ansible_become_method=sudo -# ansible_become_pass=${EDGE_USER_PASSWORD} -# EOF - -# # Test IoT/Edge OS -# sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-simplified-installer -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 -# check_result -# fi - -# # now try with blueprint user - -# # Add instance IP address into /etc/ansible/hosts -# sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF -# [ostree_guest] -# ${IGNITION_GUEST_ADDRESS} - -# [ostree_guest:vars] -# ansible_python_interpreter=/usr/bin/python3 -# ansible_user=admin -# ansible_private_key_file=${SSH_KEY} -# ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -# ansible_become=yes -# ansible_become_method=sudo -# ansible_become_pass=${EDGE_USER_PASSWORD} -# EOF - -# # Test IoT/Edge OS -# sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type=redhat -e ostree_commit="${INSTALL_HASH}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-simplified-installer -e fdo_credential="false" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 -# check_result - -# greenprint "๐Ÿงน Clean up VM" -# if [[ $(sudo virsh domstate "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url") == "running" ]]; then -# sudo virsh destroy "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url" -# fi -# sudo virsh undefine "${IMAGE_KEY}-simplified_iso_with_ignition_embedded_url" --nvram -# sudo virsh vol-delete --pool images "$LIBVIRT_IMAGE_PATH" - # embedded base64 ign config tee "$BLUEPRINT_FILE" > /dev/null <