Inventory, emitter shows more details, and minor fixes.

This commit is contained in:
Andreas B. Mundt 2024-01-11 17:23:27 +01:00
parent 00194514ab
commit 3a14705d42
4 changed files with 119 additions and 111 deletions

View file

@ -11,6 +11,8 @@ debug=false
## date of latest git commit in ansible repository:
git_date="$(date --iso-8601=seconds --date="$(git log --date=iso-strict | \
head -3 | sed -nE "s/^Date:\s+(.+)$/\1/p")")"
echo "Latest commit in git at: $git_date."
#dir="$(mktemp -d)"
dir="/tmp/emitter"
mkdir -vp "$dir"
@ -18,16 +20,19 @@ touch "$dir/${git_date//T*/}"
hlist=""
n=0
running=0
find_outdated(){
hlist=""
n=0
running=0
while IFS= read -r -d '' file ; do
running=$(( running + 1 ))
$debug && echo -n "Processing host '$file' with IP address "
d="$(sed -nE "s/\s+drwx.+([0-9]{4}-[0-9]{2}-[0-9]{2} \S+).*/\1/p" "$file" | head -1)"
if [[ -z "$d" ]] || [[ $(date --date="$d" +%s) -lt $(date --date="$git_date" +%s) ]] ; then
r='([0-9]{1,3}\.){3}[0-9]{1,3}'
ipa="$(sed -nE "s|^\s+default via.+ src ($r) metric.+|\1|p" "$file")"
ipa="$(sed -nE "s|^\s+default via.+ src ($r) metric.+|\1|p" "$file" | head -1)"
if [[ -z "$ipa" ]] ; then
# FIXME: Outdated report format, trying fallback:
ipa="$(grep -E "\s+2: en" -A3 "$file" | \
@ -44,6 +49,7 @@ find_outdated(){
fi
done < <(find "$logdir" -maxdepth 1 -type f -mmin -$age -print0)
hlist="${hlist//^,/}"
echo -n "Running hosts: $running, to be upgraded: $n. "
}
run_ansible(){