From 0e1555f12dd2376f1c9a1fbecda5d28bde62e7a9 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Thu, 3 Sep 2015 16:56:30 +0000 Subject: [PATCH] Add a check-for-updates that only checks non vms for updates. --- playbooks/check-for-nonvirt-updates.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 playbooks/check-for-nonvirt-updates.yml diff --git a/playbooks/check-for-nonvirt-updates.yml b/playbooks/check-for-nonvirt-updates.yml new file mode 100644 index 0000000000..679264ef24 --- /dev/null +++ b/playbooks/check-for-nonvirt-updates.yml @@ -0,0 +1,32 @@ +# +# simple playbook to check all hosts and see how many updates they have pending. +# It could be a lot faster if we didn't gather facts, but we need that for yum vs dnf checking +# +# If you want a pretty sorted list, you need to post process the output here with something +# like: +# +# time ansible-playbook check-for-updates.yml | grep msg\": | awk -F: '{print $2}' | sort +# + +- name: check for updates + hosts: all + gather_facts: true + user: root + + tasks: + + - name: check for updates (yum) + yum: list=updates update_cache=true + register: yumoutput + when: ansible_distribution_major_version|int < 22 and ansible_virtualization_role == 'host' + + - name: check for updates (dnf) + dnf: list=updates + register: dnfoutput + when: ansible_distribution_major_version|int > 21 and ansible_virtualization_role == 'host' + + - debug: msg="{{ inventory_hostname}} {{ yumoutput.results|length }}" + when: yumoutput is defined and yumoutput.results|length > 0 + + - debug: msg="{{ inventory_hostname}} {{ dnfoutput.results|length }}" + when: dnfoutput is defined and dnfoutput.results|length > 0