From 5c53230537f66c2efebc78c18cfb1e9d525867ee Mon Sep 17 00:00:00 2001 From: Naglfar Date: Sat, 5 Dec 2020 15:16:04 +0100 Subject: [PATCH] Move the running process to its function --- roles/common/files/ansible-run | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/roles/common/files/ansible-run b/roles/common/files/ansible-run index 28737e0..1e69089 100644 --- a/roles/common/files/ansible-run +++ b/roles/common/files/ansible-run @@ -1,14 +1,19 @@ #!/bin/bash export RUNNING="/dev/shm/ansible_is_running" +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 +} + 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 + ansible_is_running touch /dev/shm/ansible-hook-last-run rm $RUNNING exit 0