Add standalone installation option

This commit is contained in:
LinuxSquare 2025-05-30 17:44:51 +02:00
parent 2bff5fd4ed
commit 9610d0b733
Signed by: LinuxSquare
SSH key fingerprint: SHA256:vFuUYM2D47SB3YMPF55L8zeJbJwEX89d/I967NgKN0A

View file

@ -233,7 +233,7 @@ function prepareInstallation() {
# INSTALLATION_TYPE=$(dialog --clear --title "Choose the main installation type of this host" --radiolist "Select one" 10 70 3 gaming Game-Server false proxy Proxy-Server false build Build-Server false 3>&1 1>&2 2>&3 3>&-)
# standalone or managed
INSTALLATION_MODE=$(dialog --clear --title "Choose the main installation mode of this host" --radiolist "Select one" 10 70 3 controller Controller false managed Managed false 3>&1 1>&2 2>&3 3>&-)
INSTALLATION_MODE=$(dialog --clear --title "Choose the main installation mode of this host" --radiolist "Select one" 10 70 3 controller Controller false managed Managed false standalone Standalone false 3>&1 1>&2 2>&3 3>&-)
# show summary
summary
@ -392,20 +392,34 @@ function installation() {
installationSubtaskTitle "Set root shell"
runInChroot "chsh -s /usr/bin/fish root" || installationFailed
installationSubtaskTitle "Create ansible user"
runInChroot "adduser -s /usr/bin/fish -S -D ansible"
case "$INSTALLATION_MODE" in
"controller")
installationSubtaskTitle "Create ansible user"
runInChroot "adduser -s /usr/bin/fish -S -D ansible"
installationSubtaskTitle "Enable ansible passwordless sudo"
runInChroot "echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/ansible"
installationSubtaskTitle "Enable ansible passwordless sudo"
runInChroot "echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/ansible"
if [[ "$INSTALLATION_MODE" == "controller" ]]; then
installationSubtaskTitle "Generate ansible ssh-keypair"
runInChroot "sudo -u ansible 'ssh-keygen -t ed25519 -P ""'" || installationFailed
installationSubtaskTitle "Generate ansible ssh-keypair"
runInChroot "sudo -u ansible 'ssh-keygen -t ed25519 -P ""'" || installationFailed
installationSubtaskTitle "Clone Playbook-repo"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
fi
installationSubtaskTitle "Clone Playbook-repo"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
;;
"managed")
installationSubtaskTitle "Create ansible user"
runInChroot "adduser -s /usr/bin/fish -S -D ansible"
installationSubtaskTitle "Enable ansible passwordless sudo"
runInChroot "echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/ansible"
;;
"standalone")
installationSubtaskTitle "Clone Playbook-repo"
mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
;;
esac
installationSubtaskTitle "Enable btrfs module"
runInChroot "echo 'btrfs' >> /etc/modules"
@ -417,36 +431,36 @@ function installation() {
runInChroot "rc-update add udev-settle sysinit"
runInChroot "rc-update add udev-postmount default"
# echo ""
# echo "┌──────────────────────────────────────────┐"
# echo "│ Configure Ansible and playbook-run │"
# echo "└──────────────────────────────────────────┘"
# installationSubtaskTitle "Clone Playbook-repo"
# mkdir -p ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
# git clone ${INSTALLATION_ANSIBLE_GIT} ${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/playbooks
if [[ "$INSTALLATION_MODE" == "standalone" ]]; then
echo ""
echo "┌──────────────────────────────────────────┐"
echo "│ Configure Ansible and playbook-run │"
echo "└──────────────────────────────────────────┘"
# mkdir -p ${INSTALLATION_MOUNTPOINT}/etc/ansible
# cat >"${INSTALLATION_MOUNTPOINT}/etc/ansible/ansible.cfg" <<EOT || installationFailed
#[defaults]
#inventory=/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml
#EOT
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}/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml" <<EOT
#ungrouped:
# hosts:
# localhost
# vars:
# ansible_connection: local
# start_timestamp: ${START_TIMESTAMP}
# tmpfs_size: 4G
# mysql_root_password: $(randomPasswordGen 32)
# release_version: %REL_VER%
# alpine_version: %ALP_VER%
#EOT
cat >"${INSTALLATION_MOUNTPOINT}/${INSTALLATION_ANSIBLE_ROOT}/inventory.yml" <<EOT
ungrouped:
hosts:
localhost
vars:
ansible_connection: local
start_timestamp: ${START_TIMESTAMP}
tmpfs_size: 4G
mysql_root_password: $(randomPasswordGen 32)
release_version: %REL_VER%
alpine_version: %ALP_VER%
EOT
installationSubtaskTitle "Execute Ansible playbooks"
runInChroot "ansible-playbook /${INSTALLATION_ANSIBLE_ROOT}/playbooks/standalone.ansible.yml" || installationFailed
fi
# installationSubtaskTitle "Execute Ansible playbooks"
# runInChroot "ansible-playbook /${INSTALLATION_ANSIBLE_ROOT}/playbooks/top.ansible.yml" || installationFailed
echo ""
echo "┌──────────────────────────────────────────┐"