#!/bin/bash

dir=/root/tools/ansible
prj=gsb2024
opt=""

if [ -z ${UREP+x} ]; then 
	UREP=https://gitea.lyc-lecastel.fr/gsb/gsb2024.git
fi

dir=/root/tools/ansible

[ -e "${dir}" ] || mkdir -p "${dir}"

cd  "${dir}" || exit 1

if [[ $# == 1 ]] ; then
	opt=$1
fi
if [[ "${opt}" == '-l'  ]] ; then
	cd "${dir}/${prj}" || exit 2
	echo "Execution locale ...."
	ansible-playbook -i localhost, -c local  "$(hostname).yml"
else
	ansible-pull -i "$(hostname)," -U "${UREP}"
fi

exit 0