From 91c0204682eb0c2f8fe1f13bb3c1426165f9f41c Mon Sep 17 00:00:00 2001 From: Ubergeek Date: Mon, 18 Mar 2019 13:08:55 +0000 Subject: [PATCH] Added some sanity checking, to preclude concurrent runs --- roles/common/files/ansible-run | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/roles/common/files/ansible-run b/roles/common/files/ansible-run index b84c6d1..dac5e15 100644 --- a/roles/common/files/ansible-run +++ b/roles/common/files/ansible-run @@ -1,7 +1,16 @@ #!/bin/bash +export RUNNING="/dev/shm/ansible_is_running" -cd /var/thunix/ansible -/usr/bin/git pull -/usr/local/bin/ansible-playbook -i /var/thunix/ansible/hosts /var/thunix/ansible/site.yml -u root -rm /dev/shm/run-ansible -touch /dev/shm/ansible-hook-last-run +if [ -f $RUNNING ]; then + echo "Ansible is currently running." + exit 1 +else + touch $RUNNING + cd /var/thunix/ansible + /usr/bin/git pull + /usr/local/bin/ansible-playbook -i /var/thunix/ansible/hosts /var/thunix/ansible/site.yml -u root + rm /dev/shm/run-ansible + touch /dev/shm/ansible-hook-last-run + rm $RUNNING + exit 0 +fi