From 108f8f3838e3000472eb2bf9dccf3387b527645f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Robotka?= <robotka.adrian@gmail.com> Date: Sun, 10 Jan 2021 23:51:56 +0100 Subject: [PATCH] format bootstrap.sh --- playbook-template/bootstrap.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/playbook-template/bootstrap.sh b/playbook-template/bootstrap.sh index c9d6be5..96cfec9 100755 --- a/playbook-template/bootstrap.sh +++ b/playbook-template/bootstrap.sh @@ -1,12 +1,15 @@ #!/usr/bin/env bash +########################### Config #################################### + reporaw="https://git.sch.bme.hu/kszk/sysadmin/ansible/ansci/-/raw/master/playbook-template" +########################### Methods #################################### + download() { local url="$1" local dest="$2" - if command -v wget &>/dev/null - then + if command -v wget &>/dev/null; then wget "$url" -O "$dest" else curl "$url" -O "$dest" @@ -17,10 +20,12 @@ downloadFile() { download "$reporaw/$1" "$1" } +########################### Virtualenv setup #################################### + downloadFile "requirements.python.txt" -if ! command -v virtualenv &>/dev/null -then +# check existance of virtualenv command +if ! command -v virtualenv &>/dev/null; then echo "This command needs virtualenv to run." echo "Install it like this:" printf "\tpip3 install --user virtualenv\n" @@ -28,19 +33,16 @@ then exit 1 fi -if [[ ! -d .venv ]] -then - virtualenv .venv -fi +# create virtualenv if not present +[[ ! -d .venv ]] && virtualenv .venv source .venv/bin/activate pip install -r requirements.python.txt + +########################### Ansible setup #################################### + ansible-galaxy install -r requirements.galaxy.yml ansible-playbook -i inventory.yaml playbook.yml # to stay in our comfy virtualenv -if [[ -z "$SHELL" ]] -then - SHELL="bash" -fi -exec "$SHELL" +exec "${SHELL:bash}" -- GitLab