"ansible_*" variables not usable in playbook?

Howdy!

I have been enjoying Ansible (v1.3, I believe, from GitHub) but something has really got me stumped.

Question 1: Am I able to reference ansible_* facts within a playbook if the facts have been gathered? Specifically, am I able to do something like:

  • debug: ansible_kernel is {{ ansible_kernel|d(‘’) }}

It always returns empty though each node actually has this value. So I figure the “debug” or “name” cannot reference such variables because they are not run on each node but rather the ansible server?

Question 2: In what ways are the host specific facts/variables usable in a playbook? As arguments to modules?

  • command: /bin/echo ansible_kernel is {{ ansible_kernel|d(‘’) }}

If there is a paragraph on the ansible site that explains this, please point me to the page. :slight_smile: I have thoroughly read all the documentation I could find (fascinating project).

Thank you for your time,
-bo

Question 1)

They are totally usable. You just need to specify the ‘msg’ argument to the debug module as you are calling it incorrectly:

debug: msg=“My fact value is {{ ansible_kernel }}”

Question 2)

Yeah, they are usable all over the place. Take a look through github.com/ansible/ansible-examples and the “language examples” in particular, and you will see lots of examples of facts being used for all sorts of things.