From 1e981d3800bac4d9ee6d2c164826ab7184839a43 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 26 May 2023 20:47:37 +0100 Subject: [PATCH] added an ansifix script. --- usr.local.sbin/ansifix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 usr.local.sbin/ansifix diff --git a/usr.local.sbin/ansifix b/usr.local.sbin/ansifix new file mode 100644 index 0000000..217bd45 --- /dev/null +++ b/usr.local.sbin/ansifix @@ -0,0 +1,28 @@ +## "ansifix" keeps the puppet manifests updated from gitea +## a quick check confirms alterationa to local files +## else.. those are updated with latest from gitea + +set -u + +## -- path to the Ansible dirs +ANSBASE=/var/lib/ansible/ + +echo "$(date +'%F_%R:%S') ==== START ==== " + +## -- check each repo in turn +cd ${ANSBASE} + +echo -e "$(date +'%F_%R:%S') checking ${ANSBASE} ... \c" +STATUS="$(git status | tail -n1)" +if [[ ! ${STATUS} =~ "nothing to commit" ]] +then + echo "need to fix $ANSBASE, showing diff on next line" + git diff + git fetch origin &> /dev/null + git reset --hard origin/master &> /dev/null +else + echo " ${STATUS}" +fi +git pull &> /dev/null + +echo "$(date +'%F_%R:%S') ------ END ------"