This article shows the Ansible playbook used to query target systems to get their version details. Ie, the details obtained from “/etc/*release”.
---
- hosts: all
# remote_user: root
# become: yes
tasks:
- debug:
msg:
- "ansible_distribution {{ hostvars[inventory_hostname].ansible_distribution }}"
- "major version {{ hostvars[inventory_hostname].ansible_distribution_major_version }}"
- "version {{ hostvars[inventory_hostname].ansible_distribution_version }}"
You might use the above playbook as demonstrated here – where “get-os-version.yaml” is the Ansible playbook above:
ansible-playbook get-os-version.yaml -i ./hosts
Notice in the above playbook there are two lines commented out. You’re not likely to need root access.