@@ -58,18 +58,11 @@ runs:
5858 - name : Maximize build space
5959 uses : jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
6060
61- - name : Checkout repository
62- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63- with :
64- persist-credentials : false
65- repository : secureblue/bootc-integration-test-action
66- path : bootc-integration-test-action
67-
6861 - name : ' Install Dependencies'
6962 shell : bash
7063 run : |
7164 sudo apt-get update
72- sudo apt-get install -y qemu-system-x86 libvirt-daemon-system libvirt-clients virtinst podman apparmor-utils wget
65+ sudo apt-get install -y qemu-system-x86 libvirt-daemon-system libvirt-clients virtinst podman apparmor-utils wget libguestfs-tools
7366
7467 - name : ' Configure Libvirt and AppArmor'
7568 shell : bash
@@ -79,70 +72,18 @@ runs:
7972 sudo systemctl restart libvirtd
8073 sudo usermod -aG kvm,libvirt "$USER"
8174
82- - name : ' Install Butane'
83- shell : bash
84- env :
85- BUTANE_VERSION : ${{ inputs.butane-version }}
86- run : |
87- URL="https://github.com/coreos/butane/releases/download/${BUTANE_VERSION}/butane-x86_64-unknown-linux-gnu"
88- wget -q "${URL}" -O /tmp/butane
89- chmod +x /tmp/butane
90- sudo mv /tmp/butane /usr/local/bin/butane
91-
9275 - name : Generate SSH Keypair
9376 shell : bash
9477 run : |
9578 mkdir -p ~/.ssh
9679 ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
9780
98- - name : ' Create Ignition Config'
99- shell : bash
100- env :
101- VM_INTERFACE : ${{ inputs.vm-interface }}
102- VM_IP : ${{ inputs.vm-ip }}
103- BUTANE_SPEC_VERSION : ${{ inputs.butane-spec-version }}
104- run : |
105- IGNITION_DIR="/var/lib/libvirt/boot"
106- IGNITION_FILE="${IGNITION_DIR}/config.ign"
107- sudo mkdir -p "${IGNITION_DIR}"
108- SSH_PUBLIC_KEY=$(cat ~/.ssh/id_ed25519.pub)
109-
110- cat <<EOF > config.bu
111- variant: fcos
112- version: ${BUTANE_SPEC_VERSION}
113- passwd:
114- users:
115- - name: core
116- ssh_authorized_keys:
117- - "${SSH_PUBLIC_KEY}"
118- storage:
119- files:
120- - path: /etc/NetworkManager/system-connections/static.nmconnection
121- mode: 0600
122- contents:
123- inline: |
124- [connection]
125- id=static-${VM_INTERFACE}
126- type=ethernet
127- interface-name=${VM_INTERFACE}
128- [ipv4]
129- method=manual
130- addresses=${VM_IP}/24
131- gateway=192.168.122.1
132- dns=1.1.1.1
133- [ipv6]
134- method=disabled
135- EOF
136-
137- sudo butane --pretty --strict config.bu | sudo tee "${IGNITION_FILE}" > /dev/null
138- sudo chown libvirt-qemu:kvm "${IGNITION_FILE}"
139- sudo chmod 644 "${IGNITION_FILE}"
140-
14181 - name : ' Create and Start VM'
14282 shell : bash
14383 env :
14484 DISK_SIZE_GB : ${{ inputs.disk-size-gb }}
14585 IMAGE_PATH : ${{ steps.download_image.outputs.image_path }}
86+ VM_INTERFACE : ${{ inputs.vm-interface }}
14687 VM_NAME : ${{ inputs.vm-name }}
14788 VCPU : ${{ inputs.vcpus }}
14889 MEMORY_MB : ${{ inputs.memory-mb }}
@@ -166,8 +107,33 @@ runs:
166107 --rootfs btrfs \
167108 "${REGISTRY}/${IMAGE}:${BRANCH}"
168109
169- IGNITION_CONFIG="/var/lib/libvirt/boot/config.ign"
170- IGNITION_DEVICE_ARG=(--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}")
110+ mv output/qcow2/disk.qcow2 /var/lib/libvirt/images/
111+ DISK_IMAGE_PATH="/var/lib/libvirt/images/disk.qcow2"
112+ PUBKEY_PATH="$HOME/.ssh/id_ed25519.pub"
113+ sudo virt-customize -a "$DISK_IMAGE_PATH" \
114+ --run-command 'useradd -m -G wheel -s /bin/bash core' \
115+ --mkdir -p /home/core/.ssh \
116+ --upload "$PUBKEY_PATH":/tmp/id_ed25519.pub \
117+ --run-command 'cat /tmp/id_ed25519.pub > /home/core/.ssh/authorized_keys' \
118+ --run-command 'chmod 700 /home/core/.ssh && chmod 600 /home/core/.ssh/authorized_keys' \
119+ --run-command 'chown -R core:core /home/core/.ssh' \
120+ --run-command "mkdir -p /etc/NetworkManager/system-connections" \
121+ --run-command "cat > /etc/NetworkManager/system-connections/static-${VM_INTERFACE}.nmconnection <<EOF
122+ [connection]
123+ id=static-${VM_INTERFACE}
124+ type=ethernet
125+ interface-name=${VM_INTERFACE}
126+ [ipv4]
127+ method=manual
128+ addresses=${VM_IP}/24
129+ gateway=192.168.122.1
130+ dns=1.1.1.1
131+ [ipv6]
132+ method=disabled
133+ EOF
134+ " \
135+ --run-command "chmod 600 /etc/NetworkManager/system-connections/static-${VM_INTERFACE}.nmconnection"
136+
171137 sudo virt-install \
172138 --connect="qemu:///system" \
173139 --name="${VM_NAME}" \
@@ -176,9 +142,8 @@ runs:
176142 --import \
177143 --graphics=none \
178144 --os-variant="silverblue-unknown" \
179- --disk="size=${DISK_SIZE_GB},backing_store=./output/qcow2/disk.qcow2 " \
145+ --disk="size=${DISK_SIZE_GB},backing_store=${DISK_IMAGE_PATH} " \
180146 --network network=default \
181- "${IGNITION_DEVICE_ARG[@]}" \
182147 --noautoconsole
183148
184149 - name : ' Wait for VM Startup'
0 commit comments