Skip to content

Instantly share code, notes, and snippets.

@eby
Last active April 26, 2024 17:58
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save eby/740dd7ccc6bba8cd73004d33a25f10e0 to your computer and use it in GitHub Desktop.
Save eby/740dd7ccc6bba8cd73004d33a25f10e0 to your computer and use it in GitHub Desktop.
Get OS version for an inventory with ad-hoc ansible
# The setup command allows filtering facts
# More info: https://docs.ansible.com/ansible/latest/modules/setup_module.html
# inventory_file = path to inventory file (if not normal role layout)
# host_group = group to query. use all for all hosts
ansible -i inventory_file host_group -m setup -a 'filter=ansible_distribution_version'
# For a Ubuntu Bionic Host the distribution facts look like this:
# "ansible_distribution": "Ubuntu",
# "ansible_distribution_file_parsed": true,
# "ansible_distribution_file_path": "/etc/os-release",
# "ansible_distribution_file_variety": "Debian",
# "ansible_distribution_major_version": "18",
# "ansible_distribution_release": "bionic",
# "ansible_distribution_version": "18.04"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment