80 changed files with 416 additions and 352 deletions
@ -1,9 +1,9 @@ |
|||
version: 2 |
|||
ethernets: |
|||
enp1s0: |
|||
demo0: |
|||
match: |
|||
macaddress: "{{ libvirt_domain_mac_address }}" |
|||
set-name: enp1s0 |
|||
set-name: demo0 |
|||
addresses: |
|||
- "{{ libvirt_domain_parameters.ipv4_address }}" |
|||
gateway4: "{{ libvirt_domain_parameters.ipv4_gateway }}" |
|||
|
|||
@ -1,9 +1,9 @@ |
|||
version: 2 |
|||
ethernets: |
|||
enp1s0: |
|||
demo0: |
|||
match: |
|||
macaddress: "{{ libvirt_domain_mac_address }}" |
|||
set-name: enp1s0 |
|||
set-name: demo0 |
|||
addresses: |
|||
- "{{ libvirt_domain_parameters.ipv4_address }}" |
|||
gateway4: "{{ libvirt_domain_parameters.ipv4_gateway }}" |
|||
|
|||
@ -0,0 +1,22 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
|
|||
# Install virtualization packages |
|||
dnf install -y cockpit-machines libvirt libvirt-daemon-kvm virt-install virt-top \ |
|||
libguestfs-tools genisoimage smartmontools hdparm rclone virt-v2v \ |
|||
virt-v2v-bash-completion libguestfs-winsupport |
|||
dnf clean all |
|||
|
|||
EOF |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
|
|||
# Enable systemd services and sockets |
|||
systemctl enable libvirtd.service libvirt-guests.service |
|||
|
|||
EOF |
|||
@ -0,0 +1,57 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
# The standard output is used to alter the domain's XML configuration. |
|||
# Suppress all output to avoid interfering with libvirt's operation. |
|||
exec > /dev/null |
|||
|
|||
function log () { |
|||
echo "$@" >&2 |
|||
} |
|||
|
|||
# This script is called by libvirt when a VM is started or stopped. |
|||
# It is used to set up and tear down networking for the VM. |
|||
# The script takes two arguments: the VM name and the action (start or stop). |
|||
VM_NAME="$1" |
|||
ACTION="$2" |
|||
|
|||
# Check if the networking configuration file exists for the VM |
|||
if [ ! -f "/etc/libvirt-hooks/${VM_NAME}/iptables" ]; then |
|||
log "No networking configuration found for VM '$VM_NAME'. Skipping." |
|||
exit 0 |
|||
fi |
|||
|
|||
if [ "$ACTION" = "started" ] || [ "$ACTION" = "reconnect" ] || [ "$ACTION" = "restore" ]; then |
|||
log "Setting up networking for VM '$VM_NAME'..." |
|||
|
|||
# Set up iptables rules |
|||
while read -r rule; do |
|||
if [ -z "$rule" ]; then |
|||
continue |
|||
fi |
|||
iptables $rule |
|||
done < "/etc/libvirt-hooks/${VM_NAME}/iptables" |
|||
|
|||
log "Networking setup complete for VM '$VM_NAME'." |
|||
elif [ "$ACTION" = "stopped" ] || [ "$ACTION" = "disconnect" ]; then |
|||
log "Tearing down networking for VM '$VM_NAME'..." |
|||
|
|||
# Tear down iptables rules |
|||
while read -r rule; do |
|||
if [ -z "$rule" ]; then |
|||
continue |
|||
fi |
|||
# Replace '-A'/'-I' with '-D' to delete the rule |
|||
rule="${rule/-A/-D}" |
|||
rule="${rule/-I/-D}" |
|||
iptables $rule || log "Warning: Failed to delete iptables rule: iptables $rule" |
|||
done < "/etc/libvirt-hooks/${VM_NAME}/iptables" |
|||
|
|||
log "Networking teardown complete for VM '$VM_NAME'." |
|||
else |
|||
log "Unknown action '$ACTION'. Supported actions are 'started', 'stopped', 'reconnect', and 'disconnect'." |
|||
log "Skipping." |
|||
fi |
|||
|
|||
exit 0 |
|||
@ -0,0 +1,4 @@ |
|||
- if: |
|||
- path: /etc/greenboot/check/ |
|||
op: [created, updated, removed] |
|||
run: systemctl restart --no-block greenboot-healthcheck.service |
|||
@ -1,8 +0,0 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
systemctl enable nextcloud.target |
|||
EOF |
|||
@ -1,10 +0,0 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/configs/nextcloud-config.env |
|||
op: [created, updated] |
|||
run: systemctl restart nextcloud.target |
|||
timeout: 5m |
|||
- if: |
|||
- path: /etc/containers/systemd/configs/nextcloud-config.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/nextcloud.target ]; then systemctl stop nextcloud.target; fi' |
|||
timeout: 5m |
|||
@ -1,8 +0,0 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
systemctl enable migrate-vm@printserver.service |
|||
EOF |
|||
@ -1,8 +0,0 @@ |
|||
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 |
|||
@ -1,49 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
# This script is called by libvirt when a VM is started or stopped. |
|||
# It is used to set up and tear down networking for the VM. |
|||
# The script takes two arguments: the VM name and the action (start or stop). |
|||
VM_NAME="$1" |
|||
ACTION="$2" |
|||
|
|||
# Check if the networking configuration file exists for the VM |
|||
if [ ! -f "/etc/libvirt/hooks/qemu.d/${VM_NAME}/iptables" ]; then |
|||
echo "No networking configuration found for VM '$VM_NAME'. Skipping." |
|||
exit 0 |
|||
fi |
|||
|
|||
if [ "$ACTION" = "started" ] || [ "$ACTION" = "reconnect" ]; then |
|||
echo "Setting up networking for VM '$VM_NAME'..." |
|||
|
|||
# Set up iptables rules |
|||
while read -r rule; do |
|||
if [ -z "$rule" ]; then |
|||
continue |
|||
fi |
|||
iptables $rule |
|||
done < "/etc/libvirt/hooks/qemu.d/${VM_NAME}/iptables" |
|||
|
|||
echo "Networking setup complete for VM '$VM_NAME'." |
|||
elif [ "$ACTION" = "stopped" ] || [ "$ACTION" = "disconnect" ]; then |
|||
echo "Tearing down networking for VM '$VM_NAME'..." |
|||
|
|||
# Tear down iptables rules |
|||
while read -r rule; do |
|||
if [ -z "$rule" ]; then |
|||
continue |
|||
fi |
|||
# Replace '-A'/'-I' with '-D' to delete the rule |
|||
rule="${rule/-A/-D}" |
|||
rule="${rule/-I/-D}" |
|||
iptables $rule || echo "Warning: Failed to delete iptables rule: iptables $rule" |
|||
done < "/etc/libvirt/hooks/qemu.d/${VM_NAME}/iptables" |
|||
|
|||
echo "Networking teardown complete for VM '$VM_NAME'." |
|||
else |
|||
echo "Unknown action '$ACTION'. Supported actions are 'started', 'stopped', 'reconnect', and 'disconnect'." |
|||
echo "Skipping." |
|||
fi |
|||
|
|||
exit 0 |
|||
@ -1,2 +0,0 @@ |
|||
-t nat -A PREROUTING -p tcp --dport 80 -d 192.168.2.75 -j DNAT --to-destination 192.168.122.2:80 |
|||
-t filter -I LIBVIRT_FWI -d 192.168.122.2 -p tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT |
|||
@ -1 +0,0 @@ |
|||
../default.xml |
|||
@ -1,19 +0,0 @@ |
|||
<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='24' unit='hours'/> |
|||
</range> |
|||
<host mac="04:00:00:00:00:01" name="nextcloud" ip="192.168.122.2" /> |
|||
</dhcp> |
|||
</ip> |
|||
</network> |
|||
@ -1,8 +0,0 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
systemctl enable odoo.target |
|||
EOF |
|||
@ -1,10 +0,0 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/configs/odoo-config.env |
|||
op: [created, updated] |
|||
run: systemctl restart odoo.target |
|||
timeout: 5m |
|||
- if: |
|||
- path: /etc/containers/systemd/configs/odoo-config.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/odoo.target ]; then systemctl stop odoo.target; fi' |
|||
timeout: 5m |
|||
@ -0,0 +1,54 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [[ "$UID" -ne 0 ]]; then |
|||
echo "This command must be run as root!" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ "$#" -lt 1 ]; then |
|||
echo "Usage: $0 <bootc-target-image> [qcow2-target-image]" |
|||
exit 1 |
|||
fi |
|||
|
|||
TARGET_IMAGE="$1" |
|||
|
|||
OCI_REGISTRY="${TARGET_IMAGE%%/*}" |
|||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" |
|||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" |
|||
|
|||
if [ ! -f "$PROJECT_DIR/signing-key.pass" ]; then |
|||
openssl rand -base64 30 > "$PROJECT_DIR/signing-key.pass" |
|||
chmod 600 "$PROJECT_DIR/signing-key.pass" |
|||
fi |
|||
|
|||
if [ ! -f "$PROJECT_DIR/signing-key.pub" ]; then |
|||
skopeo generate-sigstore-key --output-prefix "$PROJECT_DIR/signing-key" --passphrase-file "$PROJECT_DIR/signing-key.pass" |
|||
fi |
|||
|
|||
if [ ! -f "/etc/containers/registries.d/${OCI_REGISTRY}.yaml" ]; then |
|||
tee "/etc/containers/registries.d/${OCI_REGISTRY}.yaml" > /dev/null <<EOF |
|||
docker: |
|||
${OCI_REGISTRY}: |
|||
use-sigstore-attachments: true |
|||
EOF |
|||
fi |
|||
|
|||
export REGISTRY_AUTH_FILE="$PROJECT_DIR/auth.json" |
|||
if [ ! -f "$REGISTRY_AUTH_FILE" ]; then |
|||
echo "Please enter your credentials for ${OCI_REGISTRY}:" |
|||
podman login "${OCI_REGISTRY}" |
|||
|
|||
echo "Please enter your credentials for registry.redhat.io:" |
|||
podman login registry.redhat.io |
|||
fi |
|||
|
|||
if [ -x "$PWD/custom.sh" ]; then |
|||
echo "Running custom.sh..." |
|||
"$PWD/custom.sh" |
|||
fi |
|||
|
|||
echo "Building and pushing image $TARGET_IMAGE..." |
|||
podman build --no-cache -t "${TARGET_IMAGE}" . |
|||
podman push --sign-by-sigstore-private-key "$PROJECT_DIR/signing-key.private" --sign-passphrase-file "$PROJECT_DIR/signing-key.pass" "${TARGET_IMAGE}" |
|||
@ -0,0 +1,20 @@ |
|||
FROM edge-registry.itix.fr/demo-edge-retail/base:latest |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
|
|||
# Install the Qemu guest agent |
|||
dnf install -y qemu-guest-agent |
|||
dnf clean all |
|||
|
|||
EOF |
|||
|
|||
ADD --chown=root:root root / |
|||
|
|||
RUN <<EOF |
|||
set -Eeuo pipefail |
|||
|
|||
# The flightctl-agent configuration will be injected here by the hypervisor |
|||
install -d -m 0700 -o root -g root /var/lib/private/flightctl |
|||
|
|||
EOF |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/default/migrate-vm-printserver.env |
|||
op: [created, updated] |
|||
run: /bin/sh -Eeuo pipefail -c 'systemctl enable migrate-vm@printserver.service ; systemctl restart migrate-vm@printserver.service' |
|||
timeout: 5m |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/default/migrate-vm-printserver.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/migrate-vm@.service ]; then systemctl stop migrate-vm@printserver.service ; systemctl disable migrate-vm@printserver.service ; fi' |
|||
timeout: 5m |
|||
@ -1,6 +1,12 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [ ! -f /etc/default/migrate-vm-printserver.env ]; then |
|||
echo "Virtual Machine 'printserver' not configured for this host!" |
|||
exit 0 |
|||
fi |
|||
|
|||
MAX_ATTEMPTS=60 |
|||
|
|||
for (( attempt=1; attempt<=MAX_ATTEMPTS; attempt++ )); do |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/nextcloud/nextcloud-config.env |
|||
op: [created, updated] |
|||
run: /bin/sh -Eeuo pipefail -c 'systemctl enable nextcloud.target ; systemctl restart nextcloud.target' |
|||
timeout: 5m |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/nextcloud/nextcloud-config.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/nextcloud.target ]; then systemctl stop nextcloud.target ; systemctl disable nextcloud.target ; fi' |
|||
timeout: 5m |
|||
@ -1,6 +1,12 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [ ! -f /etc/containers/systemd/nextcloud/nextcloud-config.env ]; then |
|||
echo "Nextcloud not configured for this host!" |
|||
exit 0 |
|||
fi |
|||
|
|||
declare -a container_state=() |
|||
MAX_ATTEMPTS=60 |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/odoo/odoo-config.env |
|||
op: [created, updated] |
|||
run: /bin/sh -Eeuo pipefail -c 'systemctl enable odoo.target ; systemctl restart odoo.target' |
|||
timeout: 5m |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/containers/systemd/odoo/odoo-config.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/odoo.target ]; then systemctl stop odoo.target ; systemctl disable odoo.target ; fi' |
|||
timeout: 5m |
|||
@ -1,6 +1,12 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [ ! -f /etc/containers/systemd/odoo/odoo-config.env ]; then |
|||
echo "Odoo not configured for this host!" |
|||
exit 0 |
|||
fi |
|||
|
|||
declare -a container_state=() |
|||
MAX_ATTEMPTS=60 |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/default/bootstrap-vm-nextcloud.env |
|||
op: [created, updated] |
|||
run: /bin/sh -Eeuo pipefail -c 'systemctl enable bootstrap-vm@nextcloud.service ; systemctl restart bootstrap-vm@nextcloud.service' |
|||
timeout: 5m |
|||
@ -0,0 +1,5 @@ |
|||
- if: |
|||
- path: /etc/default/bootstrap-vm-nextcloud.env |
|||
op: [removed] |
|||
run: /bin/sh -c 'if [ -f /etc/systemd/system/bootstrap-vm@.service ]; then systemctl stop bootstrap-vm@nextcloud.service ; systemctl disable bootstrap-vm@nextcloud.service ; fi' |
|||
timeout: 5m |
|||
@ -1,6 +1,12 @@ |
|||
#!/bin/bash |
|||
|
|||
set -Eeuo pipefail |
|||
|
|||
if [ ! -f /etc/default/bootstrap-vm-nextcloud.env ]; then |
|||
echo "Virtual Machine 'nextcloud' not configured for this host!" |
|||
exit 0 |
|||
fi |
|||
|
|||
MAX_ATTEMPTS=60 |
|||
|
|||
for (( attempt=1; attempt<=MAX_ATTEMPTS; attempt++ )); do |
|||
@ -0,0 +1,2 @@ |
|||
-t nat -A PREROUTING -p tcp --dport 8080 -d 192.168.2.73 -j DNAT --to-destination 192.168.122.2:8080 |
|||
-t filter -I LIBVIRT_FWI -d 192.168.122.2 -p tcp --dport 8080 -m conntrack --ctstate NEW -j ACCEPT |
|||
@ -0,0 +1,8 @@ |
|||
DOMAIN_VCPUS=4 |
|||
DOMAIN_RAM=8192 |
|||
DOMAIN_DISK_SIZE=100 |
|||
DOMAIN_OS_VARIANT=rhel9.6 |
|||
DOMAIN_MAC_ADDRESS=04:00:00:00:00:01 |
|||
FLIGHTCTL_LABELS_OVERRIDE={ "type": "virtualmachine", "vm.name": "nextcloud" } |
|||
DOMAIN_DISK_SOURCE=edge-registry.itix.fr/demo-edge-retail/virtualmachine-qcow2:latest |
|||
REGISTRY_AUTH_FILE=/etc/ostree/auth.json |
|||
@ -0,0 +1,2 @@ |
|||
-t nat -A PREROUTING -p tcp --dport 8080 -d 192.168.2.75 -j DNAT --to-destination 192.168.122.2:8080 |
|||
-t filter -I LIBVIRT_FWI -d 192.168.122.2 -p tcp --dport 8080 -m conntrack --ctstate NEW -j ACCEPT |
|||
@ -0,0 +1,16 @@ |
|||
## |
|||
## Nextcloud Configuration Environment Variables |
|||
## |
|||
|
|||
# Nextcloud domain configuration |
|||
NEXTCLOUD_TRUSTED_DOMAINS=optiplex-7000.itix.fr |
|||
OVERWRITEHOST=optiplex-7000.itix.fr:8080 |
|||
OVERWRITEPROTOCOL=http |
|||
OVERWRITECLIURL=http://optiplex-7000.itix.fr:8080 |
|||
|
|||
# Nextcloud admin credentials |
|||
NEXTCLOUD_ADMIN_USER=admin |
|||
NEXTCLOUD_ADMIN_PASSWORD=nextcloud |
|||
|
|||
# Nextcloud server info token |
|||
NEXTCLOUD_SERVERINFO_TOKEN=S3cr3t! |
|||
@ -1,6 +0,0 @@ |
|||
|
|||
|
|||
HEADS UP !!! |
|||
|
|||
This system is not configured ! |
|||
|
|||
@ -1,4 +0,0 @@ |
|||
DATABASE=redhat |
|||
ADMIN_PASSWORD=R3dH4t! |
|||
RIBBON_COLOR=rgba(255,0,0,.6) |
|||
RIBBON_NAME=Paris Wagram<br/>({db_name}) |
|||
@ -1,4 +0,0 @@ |
|||
DATABASE=redhat |
|||
ADMIN_PASSWORD=R3dH4t! |
|||
RIBBON_COLOR=rgba(0,0,255,.6) |
|||
RIBBON_NAME=Villeneuve d'Ascq<br/>({db_name}) |
|||
Loading…
Reference in new issue