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} 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 ==== " echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== "
## -- create directory if missing ## -- create directory if missing
@ -21,9 +29,10 @@ echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== "
cd ${ANSBASE} cd ${ANSBASE}
if [ ! -d ${ANSBASE}/${REPO} ] if [ ! -d ${ANSBASE}/${REPO} ]
then 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:" echo "$(date +'%F_%R:%S'): initial clone needed:"
git clone deploy:/tombstones/${REPO}.git ${ANSBASE}/${REPO} git clone deploy:/tombstones/${REPO}.git ${ANSBASE}/${REPO}
apply_ansible
elif [ -d ${ANSBASE}/${REPO} ] elif [ -d ${ANSBASE}/${REPO} ]
then then
## -- check first ## -- check first
@ -50,12 +59,11 @@ then
if [[ ! ${RESULTS} =~ "up to date" ]] if [[ ! ${RESULTS} =~ "up to date" ]]
then then
## -- looks like there's been some changes ## -- looks like there's been some changes
echo -e "$(date +'%F_%R:%S'): applying yaml from ${REPO} ..." apply_ansible
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
fi fi
fi fi
echo "$(date +'%F_%R:%S'): ------ $(basename $0) END ------" echo "$(date +'%F_%R:%S'): ------ $(basename $0) END ------"

Loading…
Cancel
Save