[WARNING]: It is unneccessary to use '{{' in loops, leave variables in loop expressions bare.

I’m getting the above warning from the title of this issue and I do understand the meaning, I just have no idea on how to find the loops where by syntax is not correct. Could the warning be extended to provide a filename and line number to display where the error occures?

​how about running this from your ansible directory:

grep with_.*{{ -r​

The meaning of this is that if you have:

with_items: “{{ foo.bar.baz }}”

You can and should just write:

with_items: foo.bar.baz

Sure thing, but I’m stuck because I have many instances with multiline stuff, e.g.

with_nested:

  • [‘a’, ‘b’, ‘c’]
  • {{ variable }}

And then a reg-ex is pretty difficult - at least to my knowledge.

That’s what I thought. But still I’d like to get some hints on where in all the files this has been found by the parser. Isn’t that possible?

Not right now.

If

grep -E ‘with_\w+:\s+"?{{’ -r .

and
grep -E “with_\w+:\s+'?{{” -r .

do not indicate the problem, then you can rule out a couple of cases.

Next try:

grep -E ‘-\s+"?{{’ -r .

and

grep -E “-\s+'?{{” -r .

That should cover the rest of the possibilities that come to mind.

(Note: I’m using multiple passes to cover off possibilities involving quotes to avoid a more complex regular expression that might not be correct).

Hope this helps.

Kal

Thanks Kal, the only item found is this:

  • name: “MySQL | Set the root password for all other domains”
    mysql_user: user=“root” password=“{{ mysql_root_password }}” host=“{{ item }}”
    with_items:
  • “127.0.0.1”
  • “::1”
  • “{{ inventory_hostname }}”
    notify: “MySQL | Restart MySQL”

Does that mean that the third item in with_items should be changed into

  • inventory_hostname

then?

no, it does not, as this is a value in a list, as opposed to the name of the list.