diff --git a/install-minion.sh b/install-minion.sh old mode 100644 new mode 100755 index 9f017b6..4d8b71e --- a/install-minion.sh +++ b/install-minion.sh @@ -33,7 +33,40 @@ else exit 1 fi -# Install Salt Minion +# === CLEANUP: Alte Salt-Installation entfernen === +echo "" +echo "=== Cleanup alte Installation ===" + +# Stop services +systemctl stop salt-minion 2>/dev/null || true +systemctl stop salt-master 2>/dev/null || true +systemctl disable salt-minion 2>/dev/null || true +systemctl disable salt-master 2>/dev/null || true + +# Purge packages +if [ "$OS" = "debian" ]; then + apt-get remove --purge -y salt-minion salt-master salt-common salt-ssh 2>/dev/null || true + apt-get autoremove -y 2>/dev/null || true +fi + +# Remove config, keys, cache +rm -rf /etc/salt +rm -rf /var/cache/salt +rm -rf /var/log/salt +rm -rf /var/run/salt +rm -rf /srv/salt +rm -rf /srv/pillar + +# Remove old repo config +rm -f /etc/apt/sources.list.d/salt*.list +rm -f /etc/apt/keyrings/salt-archive-keyring.gpg + +echo "Alte Installation bereinigt." + +# === INSTALL: Frische Installation === +echo "" +echo "=== Frische Installation ===" + if [ "$OS" = "debian" ]; then apt-get install -y gnupg2 curl >/dev/null 2>&1 curl -fsSL https://packages.broadcom.com/artifactory/api/security/keypair/SaltProjectKey/public | gpg --dearmor -o /etc/apt/keyrings/salt-archive-keyring.gpg @@ -43,6 +76,7 @@ if [ "$OS" = "debian" ]; then fi # Configure Master +mkdir -p /etc/salt/minion.d cat > /etc/salt/minion.d/master.conf << EOF master: $SALT_MASTER EOF @@ -58,7 +92,9 @@ systemctl restart salt-minion echo "" echo "=== Fertig ===" -echo "Minion installiert und gestartet." -echo "Grain 'kunde: $KUNDE' gesetzt." +echo "Salt Version: $(salt-minion --version)" +echo "Minion ID: $(hostname)" +echo "Grain: kunde: $KUNDE" +echo "Master: $SALT_MASTER" echo "" echo "Naechster Schritt: Salt Master kontaktieren fuer Key-Akzeptanz."