Update the check for updates playbooks

This commit is contained in:
Kevin Fenzi 2018-06-29 21:46:54 +00:00
parent bdbc67f18a
commit b970b7bb55
2 changed files with 59 additions and 19 deletions

View file

@ -8,25 +8,54 @@
# 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
- name: check for updates (EL)
hosts: virt_host:&distro_RedHat
gather_facts: false
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'
- debug: msg="{{ inventory_hostname}} {{ yumoutput.results|length }}"
- name: check for updates (Fedora)
hosts: virt_host:&distro_Fedora
gather_facts: false
tasks:
- name: check for updates (dnf)
dnf: list=updates
register: dnfoutput
- debug: msg="{{ inventory_hostname}} {{ dnfoutput.results|length }}"
#
# For some reason ansible detects aarch64/armv7 hosts as virt type "NA"
#
- name: check for updates (aarch64/armv7) EL
hosts: virt_NA:&distro_RedHat
gather_facts: false
tasks:
- name: check for updates (yum)
yum: list=updates update_cache=true
register: yumoutput
- debug: msg="{{ inventory_hostname}} {{ yumoutput.results|length }}"
- name: check for updates (aarch64/armv7) Fedora
hosts: virt_NA:&distro_Fedora
gather_facts: false
tasks:
- 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

View file

@ -9,24 +9,35 @@
#
- name: check for updates
hosts: all
gather_facts: true
user: root
hosts: distro_RedHat:distro_CentOS:!*.app.os.fedoraproject.org:!*.app.os.stg.fedoraproject.org
gather_facts: false
tasks:
- name: check for updates (yum)
yum: list=updates update_cache=true
register: yumoutput
when: ansible_distribution_major_version|int < 22
- debug: msg="{{ inventory_hostname}} {{ yumoutput.results|length }}"
when: yumoutput.results|length > 0
- name: check for updates
hosts: distro_Fedora:!*.app.os.fedoraproject.org:!*.app.os.stg.fedoraproject.org
gather_facts: false
tasks:
#
# We use the command module here because the real module can't expire
#
- name: make dnf recheck for new metadata from repos
command: dnf clean expire-cache
warn: False
- name: check for updates (dnf)
dnf: list=updates
register: dnfoutput
when: ansible_distribution_major_version|int > 21
- 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
when: dnfoutput.results|length > 0