Skip to content

Instantly share code, notes, and snippets.

@recall704
Forked from eby/ansible-fact.sh
Created April 2, 2024 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save recall704/3316508166314fe7addbadad05b3ae77 to your computer and use it in GitHub Desktop.
Save recall704/3316508166314fe7addbadad05b3ae77 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