"facts" don't evaluate

Hi,
I’m new to ansible and I’m trying to figure out how to use “facts”.

I have this playbook

Public service announcement – First off, please do not use $foo in any version of Ansible 1.2 or later, as this is a deprecated syntax, and mixing $foo and {{ foo }} is a bit strange. It is much less confusing when working with variables and other things.

To answer your question though, task names never show inventory variables. Why? The task headers are printed for multiple servers, maybe hundreds, and there is no way the variable would be the same for all them in most cases.

To debug the value, do this instead as a task:

  • debug: msg={{ ansible_hostname }}

and so on.

Public service announcement – First off, please do not use $foo in any version of Ansible 1.2 or later, as this is a deprecated syntax, and mixing $foo and {{ foo }} is a bit strange. It is much less confusing when working with variables and other things.

Well put, I should have prefixed with “kids, don’t do this at home”, since I was just trying to debug if any of the known syntaxes worked.

To answer your question though, task names never show inventory variables. Why? The task headers are printed for multiple servers, maybe hundreds, and there is no way the variable would be the same for all them in most cases.

Makes sense, I only experimented with one server and didn’t think of that.

To debug the value, do this instead as a task:

  • debug: msg={{ ansible_hostname }}

and so on.

It all makes sense and I can continue studying this nice tool.

Thank you very much,
Riccardo