jinja in task (template)

Hi to all,
I have problem with evaluating jinja2 code in task (template)

This is playbook for test, just to see If I get what I want

Where you are defining the template task you should put double quotes round the jina code

e.g “{% for i in item.config_files %} src={{i}}.j2 dest={{item.FS}}/{{i}} {% endfor %}” otherwise the jinja syntax will not be evaluated.

I have however never used a for loop in this fashion so no idea if that will work, I would be interested to hear if it does.

Kind Regards

I tried that also…but got error:

fatal: [host1]: FAILED! => {“failed”: true, “msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘i’ is undefined\n\nThe error appears to have been in ‘/etc/ansible/template_jinja_eval2.yml’: line 11, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: Printing message\n ^ here\n”}

Dana četvrtak, 15. prosinca 2016. u 12:23:24 UTC+1, korisnik Greg Langford napisao je: