feat(nixos): add control center host with hypervisor gitops service
This commit is contained in:
parent
89cec4e0f3
commit
dc9b7a30d9
10 changed files with 259 additions and 42 deletions
39
scripts/hypervisor-sync.sh
Normal file
39
scripts/hypervisor-sync.sh
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script pulls the latest changes from the Git repository
|
||||
# and runs OpenTofu to provision the hypervisor state.
|
||||
# Usage: ./hypervisor-sync.sh <REPO_URL> <OPENTOFU_DIR>
|
||||
|
||||
REPO_URL=${1:-"https://git.depeuter.dev/Bos55/nix-config.git"}
|
||||
OPENTOFU_DIR=${2:-"opentofu/nodes/mikoshi"}
|
||||
|
||||
echo "Starting Hypervisor GitOps sync..."
|
||||
|
||||
if [ ! -d "nix-config" ]; then
|
||||
echo "Cloning repository from $REPO_URL..."
|
||||
git clone "$REPO_URL" nix-config
|
||||
fi
|
||||
|
||||
cd nix-config || exit
|
||||
|
||||
git fetch origin main
|
||||
|
||||
LOCAL=$(git rev-parse HEAD)
|
||||
REMOTE=$(git rev-parse origin/main)
|
||||
|
||||
if [ "$LOCAL" = "$REMOTE" ]; then
|
||||
echo "Already up to date. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Changes detected. Updating from $LOCAL to $REMOTE..."
|
||||
git reset --hard origin/main
|
||||
|
||||
echo "Applying OpenTofu changes in $OPENTOFU_DIR..."
|
||||
cd "$OPENTOFU_DIR" || exit
|
||||
|
||||
tofu init -upgrade
|
||||
|
||||
tofu apply -auto-approve
|
||||
|
||||
echo "Hypervisor GitOps sync completed successfully."
|
||||
Loading…
Add table
Add a link
Reference in a new issue