Improve the ansible scheduler

This commit is contained in:
Blade of Darkness 2021-08-16 16:40:08 +02:00
parent 04e89eb481
commit ed2926e8f9
1 changed files with 6 additions and 6 deletions

View File

@ -1,22 +1,22 @@
#!/bin/bash
export RUNNING="/dev/shm/ansible_is_running"
export HOOK="/dev/shm/ansible-hook-last-run"
export SCHED="/dev/shm/ansible_scheduler"
# sets ansible scheduling
touch $SCHED
export PATHMODIFIED="/dev/shm/run-ansible"
export SCHED=1
if [ -f $RUNNING ]; then
echo "Ansible is currently running."
else
cd /var/thunix/ansible
while [ -f $SCHED ]
while [ $SCHED = 1 ]
do
rm $SCHED
touch $RUNNING
/usr/bin/git pull
/usr/local/bin/ansible-playbook -i /var/thunix/ansible/hosts /var/thunix/ansible/site.yml -u root
touch $HOOK
[ "$PATHMODIFIED" -ot "$RUNNING" ] && SCHED=0
! [ -f "$PATHMODIFIED" ] && SCHED=0
done
rm $RUNNING
fi