From 7b6edbfe441982fd158800c8ec9309edf6920152 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Wed, 15 Jan 2025 18:43:44 +0000 Subject: [PATCH] Add check-updates script --- playbooks/manual/check-updates.yml | 23 +++++++++++++++++++++++ scripts/check-updates | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 playbooks/manual/check-updates.yml create mode 100755 scripts/check-updates diff --git a/playbooks/manual/check-updates.yml b/playbooks/manual/check-updates.yml new file mode 100644 index 0000000..1045eb0 --- /dev/null +++ b/playbooks/manual/check-updates.yml @@ -0,0 +1,23 @@ +--- +- hosts: all + gather_facts: true + tasks: + - name: Check updates (Linux) + ansible.builtin.command: + argv: + - dnf + - -q + - check-update + register: result + changed_when: result.rc == 100 + failed_when: result.rc not in [0, 100] + when: ansible_os_family == "RedHat" + + - name: Check updates (OpenBSD) + ansible.builtin.command: + argv: + - syspatch + - -c + register: result + changed_when: result.stdout != "" + when: ansible_os_family == "OpenBSD" diff --git a/scripts/check-updates b/scripts/check-updates new file mode 100755 index 0000000..5a00e56 --- /dev/null +++ b/scripts/check-updates @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eu + +if [ $# -eq 1 ]; then + limit="$1" +elif [ $# -ne 0 ]; then + echo "Usage: $(basename "$0") [hostname]" 1>&2 + exit 1 +else + limit="all" +fi + +cd "$(dirname "$0")/.." + +ansible-playbook playbooks/manual/check-updates.yml -l "$limit"