Files
ansible/roles/common/files/ansible-run

24 lines
551 B
Plaintext
Raw Normal View History

#!/bin/bash
export RUNNING="/dev/shm/ansible_is_running"
2020-12-05 18:09:03 +01:00
export HOOK="/dev/shm/ansible-hook-last-run"
2021-08-16 16:40:08 +02:00
export PATHMODIFIED="/dev/shm/run-ansible"
export SCHED=1
2020-12-05 18:36:23 +01:00
if [ -f $RUNNING ]; then
echo "Ansible is currently running."
else
2020-12-10 16:45:00 +01:00
cd /var/thunix/ansible
2021-08-16 16:40:08 +02:00
while [ $SCHED = 1 ]
2020-12-05 18:36:23 +01:00
do
2021-09-24 19:59:20 +02:00
sleep 1
touch $RUNNING
2020-12-10 16:45:00 +01:00
/usr/bin/git pull
/usr/local/bin/ansible-playbook -i /var/thunix/ansible/hosts /var/thunix/ansible/site.yml -u root
2020-12-05 18:36:23 +01:00
touch $HOOK
2021-08-16 16:40:08 +02:00
[ "$PATHMODIFIED" -ot "$RUNNING" ] && SCHED=0
! [ -f "$PATHMODIFIED" ] && SCHED=0
2020-12-05 18:36:23 +01:00
done
2020-12-07 16:32:19 +01:00
rm $RUNNING
fi