How can I use Ansible nested variable?

Question:

I have an Ansible playbook like the one below, I want use nested variable like this:
msg={{{{Component}}.community_release_num}}, but when I run playbook:

error messages

Can Ansible use nested variable, if yes, how to use it?

Answer:

Per Ansible FAQ:

Another rule is ‘moustaches don’t stack’. We often see this:

The above DOES NOT WORK, if you need to use a dynamic variable use the
hostvars or vars dictionary as appropriate:

So in your case:

Or:

Or (since Ansible 2.5):

Leave a Reply