Add quotes to elemens of the list in jinja2 (ansible)

Question:

I have very simple line in the template:

And I have list for ip:

But application wants IPs with quotes (ip=’1.1.1.1′, ‘2.2.2.2’).

I can do it like this:

But it is very ugly. Is any nice way to add quotes on each element of the list in ansible?

Thanks!

Answer:

Actually there is a very simple method to achieve this:

The filter map iterates over every item and let quote process it. Afterwards you can easily join them together.

Leave a Reply