Evaluate dynamic variable name in ansible


I have vars where I put something like this:

in my ansbile file I load the vars with

This is how I initialize m_name:

and after that I have task with iterate using with_items:

But I’ve got as output

not their values.

OK I find that if I use debug var it is working. But If I want to put this expression "{{ (item + '_port') }}" for an example in shell task it does not evaluate it. Is there a way to evaluate the dynamically created variables name – to get the value?



Leave a Reply