2019-03-18 12:53:49 +00:00
|
|
|
#!/bin/bash
|
2019-03-18 13:08:55 +00:00
|
|
|
export RUNNING="/dev/shm/ansible_is_running"
|
2020-12-05 17:09:03 +00:00
|
|
|
export HOOK="/dev/shm/ansible-hook-last-run"
|
2021-08-16 14:40:08 +00:00
|
|
|
export PATHMODIFIED="/dev/shm/run-ansible"
|
|
|
|
export SCHED=1
|
2020-12-05 17:36:23 +00:00
|
|
|
|
2019-03-18 13:08:55 +00:00
|
|
|
if [ -f $RUNNING ]; then
|
|
|
|
echo "Ansible is currently running."
|
|
|
|
else
|
2020-12-10 15:45:00 +00:00
|
|
|
cd /var/thunix/ansible
|
2021-08-16 14:40:08 +00:00
|
|
|
while [ $SCHED = 1 ]
|
2020-12-05 17:36:23 +00:00
|
|
|
do
|
2021-09-24 17:59:20 +00:00
|
|
|
sleep 1
|
2021-08-16 14:22:55 +00:00
|
|
|
touch $RUNNING
|
2020-12-10 15:45:00 +00: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 17:36:23 +00:00
|
|
|
touch $HOOK
|
2021-08-16 14:40:08 +00:00
|
|
|
|
|
|
|
[ "$PATHMODIFIED" -ot "$RUNNING" ] && SCHED=0
|
|
|
|
! [ -f "$PATHMODIFIED" ] && SCHED=0
|
2020-12-05 17:36:23 +00:00
|
|
|
done
|
2020-12-07 15:32:19 +00:00
|
|
|
rm $RUNNING
|
2019-03-18 13:08:55 +00:00
|
|
|
fi
|