- 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 - 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