|
|
|
@ -22,10 +22,8 @@ readonly INSTALLATION_ESP_PARTITION_SIZE=4
|
|
|
|
|
readonly INSTALLATION_MOUNTPOINT='/mnt'
|
|
|
|
|
readonly INSTALLATION_NOVERIA_BIN='/usr/local/noveria/bin'
|
|
|
|
|
readonly INSTALLATION_SECRETS_FILE="/root/installation.secrets"
|
|
|
|
|
readonly INSTALLATION_SALT_ROOT="srv/salt"
|
|
|
|
|
readonly INSTALLATION_SALT_GIT="https://git.noveria.org/Novos/salt-statetree.git"
|
|
|
|
|
readonly INSTALLATION_PILLAR_ROOT="srv/pillar"
|
|
|
|
|
readonly INSTALLATION_PILLAR_GIT="https://git.noveria.org/Novos/salt-pillartree.git"
|
|
|
|
|
readonly INSTALLATION_ANSIBLE_ROOT="srv/ansible"
|
|
|
|
|
readonly INSTALLATION_ANSIBLE_GIT="https://git.noveria.org/Novos/ansible-playbooks.git"
|
|
|
|
|
readonly INSTALLATION_ALPINE_VERSION=$(cat /etc/os-release | grep VERSION_ID | cut -d= -f2)
|
|
|
|
|
|
|
|
|
|
# Colors
|
|
|
|
@ -357,8 +355,8 @@ function installation() {
|
|
|
|
|
installationSubtaskTitle "Overwrite default repositories"
|
|
|
|
|
cp /etc/apk/repositories "${INSTALLATION_MOUNTPOINT}/etc/apk/repositories" || installationFailed
|
|
|
|
|
|
|
|
|
|
installationSubtaskTitle "Install SaltStack"
|
|
|
|
|
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "apk add salt-minion envsubst" || installationFailed
|
|
|
|
|
installationSubtaskTitle "Install Ansible"
|
|
|
|
|
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "apk add ansible envsubst" || installationFailed
|
|
|
|
|
|
|
|
|
|
installationSubtaskTitle "Setup keymap"
|
|
|
|
|
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "setup-keymap ch ch" || installationFailed
|
|
|
|
@ -386,59 +384,31 @@ function installation() {
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "┌──────────────────────────────────────────┐"
|
|
|
|
|
echo "│ Configure SaltStack and highstate │"
|
|
|
|
|
echo "│ Configure Ansible and playbook-run │"
|
|
|
|
|
echo "└──────────────────────────────────────────┘"
|
|
|
|
|
|
|
|
|
|
installationSubtaskTitle "Clone Salt-Repo"
|
|
|
|
|
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}
|
|
|
|
|
git clone ${INSTALLATION_SALT_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}
|
|
|
|
|
installationSubtaskTitle "Clone Playbook-repo"
|
|
|
|
|
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
|
|
|
|
|
git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
|
|
|
|
|
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/etc/salt/minion" <<EOT || installationFailed
|
|
|
|
|
---
|
|
|
|
|
state_verbose: False
|
|
|
|
|
file_client: local
|
|
|
|
|
file_roots:
|
|
|
|
|
base:
|
|
|
|
|
- /srv/salt
|
|
|
|
|
pillar_roots:
|
|
|
|
|
base:
|
|
|
|
|
- /srv/pillar
|
|
|
|
|
...
|
|
|
|
|
mkdir -p ${INSTALLATION_MOUNTPOINT}/etc/ansible
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/etc/ansible/ansible.cfg" <<EOT || installationFailed
|
|
|
|
|
[defaults]
|
|
|
|
|
inventory=/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/etc/salt/grains" <<EOT || installationFailed
|
|
|
|
|
os: Alpine
|
|
|
|
|
os_family: Alpine
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml" <<EOT
|
|
|
|
|
ungrouped:
|
|
|
|
|
hosts:
|
|
|
|
|
localhost
|
|
|
|
|
vars:
|
|
|
|
|
ansible_connection: local
|
|
|
|
|
start_timestamp: ${START_TIMESTAMP}
|
|
|
|
|
tmpfs_size: 4G
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}/serverspecific.sls" <<SERVERSPECIFIC || installationFailed
|
|
|
|
|
include:
|
|
|
|
|
SERVERSPECIFIC
|
|
|
|
|
|
|
|
|
|
for additional in ${ADDITIONAL_STATES_ARR[@]}; do
|
|
|
|
|
echo -e " - $additional" >> "${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT}/serverspecific.sls"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
installationSubtaskTitle "Populate Pillars"
|
|
|
|
|
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}
|
|
|
|
|
#git clone ${INSTALLATION_PILLAR_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/top.sls" << EOT
|
|
|
|
|
base:
|
|
|
|
|
'*':
|
|
|
|
|
EOT
|
|
|
|
|
for state in $(find ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_SALT_ROOT} -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d -exec basename {} \;); do
|
|
|
|
|
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/${state}
|
|
|
|
|
touch ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/${state}/init.sls
|
|
|
|
|
echo -e " - $state" >> ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/top.sls
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_PILLAR_ROOT}/system/init.sls" << EOT
|
|
|
|
|
system.disks.timestamp: ${START_TIMESTAMP}
|
|
|
|
|
system.disks.tmpfs.size: 4G
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
|
|
installationSubtaskTitle "Salt highstate"
|
|
|
|
|
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "salt-call state.highstate" || installationFailed
|
|
|
|
|
installationSubtaskTitle "Execute Ansible playbooks"
|
|
|
|
|
chroot "${INSTALLATION_MOUNTPOINT}" /bin/ash -c "ansible-playbook /${INSTALLATION_ANSIBLE_ROOT}/playbooks/top.ansible.yml" || installationFailed
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "┌──────────────────────────────────────────┐"
|
|
|
|
@ -480,17 +450,18 @@ EOT
|
|
|
|
|
# remove shell histories
|
|
|
|
|
rm -f /root/.zsh_history
|
|
|
|
|
|
|
|
|
|
dialog --stdout --clear --cr-wrap --no-collapse --yes-label "Reboot" --no-label "Alpine shell" --yesno "\n Installation finished" 7 50
|
|
|
|
|
case $? in
|
|
|
|
|
0) reboot ;;
|
|
|
|
|
1)
|
|
|
|
|
clear
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
255)
|
|
|
|
|
clear
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
selected_option=$(dialog --output-fd 1 --menu "What would you like to do?" 10 70 5 reboot "Reboot into your newly installed system" poweroff "Shut down the current live system" alpine-shell "Switch to an interactive shell")
|
|
|
|
|
case "$selected_option" in
|
|
|
|
|
"reboot")
|
|
|
|
|
reboot
|
|
|
|
|
;;
|
|
|
|
|
"poweroff")
|
|
|
|
|
poweroff
|
|
|
|
|
;;
|
|
|
|
|
"alpine-shell")
|
|
|
|
|
clear
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|