#!/usr/bin/bash SUDO="" # SUDO="sudo" WORKDIR="/tmp/ansible_setup" if [ "$(whoami)" == "root" ]; then SUDO="" fi fail() { >&2 echo "ERROR: ${1}" >&2 echo "EXIT 1" exit 1 } if ! which ansible-playbook; then ${SUDO} apt update ${SUDO} apt install -y ansible unzip wget || fail "Failed to install ansible!" fi # useradd -m nige # groupadd admin # usermod -a -G admin nige cd /tmp wget https://git.gerstner.se/nils/ansible_setup/archive/main.zip unzip main.zip cd ${WORKDIR} || fail "Could not change to work directory!" ansible-playbook local.yml || fail "Failed to execute ansible playbook" # ansible-playbook all.yml || fail "Failed to execute ansible playbook" echo "ALL DONE" exit 0