Viewing available Ansible facts

This article was published 3 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

When writing playbooks, you may want to perform different actions depending on what kind of machine you’re running against. Ansible provides facts about a machine that you can use to filter down to the actions you need.

These facts are unique to each machine, so sometimes it’s difficult to know what’s available. If you’re wondering about a machine, you can always use the ansible command line tool to view them all. The ones that you’re interested in will usually be prefixed with ansible_.

To view all available facts:

ansible all -i /path/to/inventory -m setup

If you’re only only interested in a certain section (e.g. which programming languages are installed on a machine) you can provide one of the keys from the result as an argument:

ansible all -i /path/to/inventory -m setup -a "filter=ohai_languages"

Thoughts on this post

last week I stumbled upon a post from @kianryan from 5 years ago. Now I find this blog post where i find i’m 3 years behind you. is the internet getting smaller?

Leave a comment?

Leave a Reply