11 changed files with 128 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
systemctl enable bootstrap-vm@nextcloud.service |
|||
EOF |
|||
@ -0,0 +1,26 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [[ "$UID" -ne 0 ]]; then |
|||
echo "This command must be run as root!" |
|||
exit 1 |
|||
fi |
|||
|
|||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" |
|||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" |
|||
|
|||
. "$PROJECT_DIR/config.env" |
|||
|
|||
function bootc_image_builder () { |
|||
local config="$1" |
|||
shift |
|||
podman run --rm -it --privileged --pull=newer --security-opt label=type:unconfined_t -v "$config:/$(basename $config):ro" \ |
|||
-v $PWD/root/usr/local/libvirt/images/nextcloud:/output -v /var/lib/containers/storage:/var/lib/containers/storage \ |
|||
registry.redhat.io/rhel10/bootc-image-builder:latest --config "/$(basename $config)" "$@" |
|||
} |
|||
|
|||
BOOTC_IMAGE="$(echo -n "$TARGET_IMAGE_TEMPLATE" | SCENARIO=scenario1 envsubst)" |
|||
echo "Building qcow2 from $BOOTC_IMAGE..." |
|||
bootc_image_builder "$PWD/config.toml" --type qcow2 "$BOOTC_IMAGE" |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
DOMAIN_VCPUS=4 |
|||
DOMAIN_RAM=8192 |
|||
DOMAIN_DISK_SIZE=100 |
|||
DOMAIN_OS_VARIANT=rhel9.6 |
|||
DOMAIN_MAC_ADDRESS=04:00:00:00:00:01 |
|||
@ -0,0 +1,20 @@ |
|||
#!/bin/bash |
|||
|
|||
exit 0 # Temporary disable the check |
|||
|
|||
set -Eeuo pipefail |
|||
MAX_ATTEMPTS=60 |
|||
|
|||
for (( attempt=1; attempt<=MAX_ATTEMPTS; attempt++ )); do |
|||
echo "Checking VM ($attempt/$MAX_ATTEMPTS)..." |
|||
|
|||
if virsh domstate nextcloud | grep -q 'running'; then |
|||
echo "Nextcloud VM is running." |
|||
exit 0 |
|||
fi |
|||
|
|||
sleep 5 |
|||
done |
|||
|
|||
echo "Nextcloud VM is not running correctly after $MAX_ATTEMPTS attempts!" |
|||
exit 1 |
|||
@ -0,0 +1 @@ |
|||
../default.xml |
|||
@ -0,0 +1,19 @@ |
|||
<network> |
|||
<name>default</name> |
|||
<bridge name="virbr0" stp="on" delay="5" /> |
|||
<forward mode='nat' /> |
|||
<domain name="libvirt.test" /> |
|||
<dns> |
|||
<host ip='192.168.122.1'> |
|||
<hostname>host</hostname> |
|||
</host> |
|||
</dns> |
|||
<ip address="192.168.122.1" netmask="255.255.255.0" localPtr="yes"> |
|||
<dhcp> |
|||
<range start="192.168.122.100" end="192.168.122.200"> |
|||
<lease expiry='1' unit='days'/> |
|||
</range> |
|||
<host mac="04:00:00:00:00:01" name="vm.libvirt.test" ip="192.168.122.2" /> |
|||
</dhcp> |
|||
</ip> |
|||
</network> |
|||
@ -0,0 +1,17 @@ |
|||
[Unit] |
|||
Description=RHDE VM Bootstrap Service |
|||
Documentation=man:systemd.service(5) |
|||
|
|||
# Only start if the VM root disk does not exist |
|||
#ConditionPathExists=!/var/lib/libvirt/images/%i/root.qcow2 |
|||
ConditionPathExists=/dummy |
|||
|
|||
[Service] |
|||
Type=oneshot |
|||
Persistent=true |
|||
#ExecStartPre=/usr/local/bin/configure-network.sh |
|||
ExecStart=/usr/local/bin/bootstrap-vm.sh %i |
|||
EnvironmentFile=/etc/default/bootstrap-vm-%i.env |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
|||
@ -0,0 +1,25 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [[ $# -ne 1 ]]; then |
|||
echo "Usage: $0 <vm-name>" |
|||
exit 1 |
|||
fi |
|||
|
|||
VM="${1}" |
|||
|
|||
cp -a "/usr/local/libvirt/images/nextcloud/qcow2/disk.qcow2" "/var/lib/libvirt/images/${VM}/root.qcow2" |
|||
|
|||
virt-install --name "${VM}" \ |
|||
--autostart \ |
|||
--cpu=host-passthrough \ |
|||
--vcpus=${DOMAIN_VCPUS} \ |
|||
--ram=${DOMAIN_RAM} \ |
|||
--os-variant=${DOMAIN_OS_VARIANT} \ |
|||
--disk=path=/var/lib/libvirt/images/${VM}/root.qcow2,bus=virtio,format=qcow2,size=${DOMAIN_DISK_SIZE}G \ |
|||
--console=pty,target_type=virtio \ |
|||
--serial=pty \ |
|||
--graphics=none \ |
|||
--import \ |
|||
--network=network=bridged,mac=${DOMAIN_MAC_ADDRESS} |
|||
@ -0,0 +1,2 @@ |
|||
qcow2 |
|||
manifest-qcow2.json |
|||
Loading…
Reference in new issue