I’m attempting to get Ansible to check CentOS and RedHat OS versions. If the version is less than 7.9 then it will list: Hostnames - OS Version in an email. However, Ansible does not appear to be evaluating this properly because I receive an email list of machines with version 7.9.:
VMGUEST03 - REDHAT 7.8
VMGUEST01 - REDHAT 7.9
VMGUEST02 - REDHAT 7.8
Does anyone know how I can correct this?
Here’s my Playbook:
- name: COLLECT INFORMATION ON ALL MACHINES
set_fact:
machine_info:
“{% for host in ansible_play_batch %}{% if ansible_facts.distribution_version | float < 7.9 %}{{ hostvars[host][‘ansible_hostname’] }} - {{ hostvars[host][‘ansible_distribution’] }} {{ hostvars[host][‘ansible_distribution_version’] }}
{% endif %}{% endfor %}”
run_once: yes
ignore_errors: True