diff --git a/Ubuntu-22/ubuntu-22.pkr.hcl b/Ubuntu-22/ubuntu-22.pkr.hcl index c76e9f1..4d5a0b7 100644 --- a/Ubuntu-22/ubuntu-22.pkr.hcl +++ b/Ubuntu-22/ubuntu-22.pkr.hcl @@ -74,4 +74,9 @@ build { "scripts/remove-snap.sh" ] } + + provisioner "file" { + source = "scripts/initial-setup.sh" + destination = "/home/xadmin/initial-setup.sh" + } } diff --git a/scripts/initial-setup.sh b/scripts/initial-setup.sh new file mode 100644 index 0000000..c8f2571 --- /dev/null +++ b/scripts/initial-setup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +SALT_MASTER='salt-v1.int.metaunix.net' + +# determine OS version +if [ -f '/etc/redhat-release' ]; then + OS="debian" +elif [ -f '/etc/debian-release' ]; then + OS="rhel" +elif [ -d '/etc/ubuntu-advantage' ]; then + OS="ubuntu" +else + OS="freebsd" +fi + +read -p 'System hostname: ' HOSTNAME +read -p 'System domain: ' DOMAIN + +if [ "$OS" = 'freebsd' ]; then + echo "$HOSTNAME.$DOMAIN" > /usr/local/etc/salt/minion_id + sed -i .orig "s/\#master: salt/master: $SALT_MASTER/" /usr/local/etc/salt/minion + rm -rf /usr/local/etc/salt/pki + + sysrc salt_minion_enable="YES" + service salt_minion start +else + echo "$HOSTNAME.$DOMAIN" > /etc/salt/minion_id + sed -i "s/\#master: salt/master: $SALT_MASTER/" /etc/salt/minion + rm -rf /etc/salt/pki + + systemctl enable salt-minion + systemctl start salt-minion +fi