#!/bin/bash
# Maintainer: Martin Weise <martin.weise@tuwien.ac.at>
# Short:      Installs the virtual machines
# Synopsis:   ./bin/setup

echo -e "SETUP [Dependencies] ***********************************************************"

export PATH="/usr/bin:$PATH"

# Install Ansible dependencies
ansible-galaxy collection install community.crypto ansible.posix community.libvirt community.general > /dev/null
echo -e "\e[92mok: [localhost]\e[39m\n"

echo -e "SETUP [Start automated install] ************************************************"

# Start the Ansible automated debug
ansible-playbook ./setup.yml

status=$?
if [ $status -eq 0 ]; then
  echo -e "SETUP [Done] *******************************************************************"
  echo -e "\e[92mok: [localhost]\e[39m\n"
  exit 0
else
  echo -e "SETUP [Done] *******************************************************************"
  echo -e "\e[91mfailed: playbook returned non-zero exit code\e[39m"
  exit 1
fi