Browse Source

Fixing the "apply" function - gets called to apply the ansible configs

(now just need to cron it)
master
dave 8 months ago
parent
commit
e5ef86d78c
  1. 16
      usr.local.sbin/update-and-apply-ansible.sh

16
usr.local.sbin/update-and-apply-ansible.sh

@ -13,6 +13,14 @@ BASE="ts-el9.local"
INVENTORY=${ANSBASE}/${REPO}
function apply_ansible
{
cd ${ANSBASE}/${REPO}
echo -e "$(date +'%F_%R:%S'): applying yaml from ${REPO} ..."
ansible-playbook -D -i ${ANSBASE}/${REPO}/inventory -l ${BASE} ${ANSBASE}/${REPO}/standalone-playbooks/epel.yml
ansible-playbook -D -i ${ANSBASE}/${REPO}/inventory -l ${BASE} ${ANSBASE}/${REPO}/site.yml
}
echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== "
## -- create directory if missing
@ -21,9 +29,10 @@ echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== "
cd ${ANSBASE}
if [ ! -d ${ANSBASE}/${REPO} ]
then
## -- initial clone here if dir is missing
## -- initial clone here if dir is missing (and initial apply)
echo "$(date +'%F_%R:%S'): initial clone needed:"
git clone deploy:/tombstones/${REPO}.git ${ANSBASE}/${REPO}
apply_ansible
elif [ -d ${ANSBASE}/${REPO} ]
then
## -- check first
@ -50,12 +59,11 @@ then
if [[ ! ${RESULTS} =~ "up to date" ]]
then
## -- looks like there's been some changes
echo -e "$(date +'%F_%R:%S'): applying yaml from ${REPO} ..."
ansible-playbook -D -i ${ANSBASE}/${REPO}/inventory -l ${BASE} ${ANSBASE}/${REPO}/standalone-playbooks/epel.yml
ansible-playbook -D -i ${ANSBASE}/${REPO}/inventory -l ${BASE} ${ANSBASE}/${REPO}/site.yml
apply_ansible
fi
fi
echo "$(date +'%F_%R:%S'): ------ $(basename $0) END ------"

Loading…
Cancel
Save