Use included circles and expressions in 'with_items' and 'when' statement

28 views
Skip to first unread message

Александр Лозовской

unread,
Nov 13, 2014, 3:56:34 AM11/13/14
to ansible...@googlegroups.com
Hi!

I have a problem with with_items+when statement, please help me. In Jinja2 syntax it's like this:

- debug: msg="{% for item in vfiles%}{% for bin in item.binaries %}{% if
 bin.name+'.'+bin.ext in files.stdout_lines %}{{item.container}}{% endif
 %}{% endfor %}{% endfor %}"



P.S. Sorry for my english.

Александр Лозовской

unread,
Nov 13, 2014, 5:28:10 AM11/13/14
to ansible...@googlegroups.com
Now i use

  - set_fact: tmpvar="{% for item in vfiles%}{% for bin in item.binaries %}{% if bin.name+'.'+bin.ext in files.stdout_lines %}{{item.container}} {% endif %}{% endfor %}{% endfor %}"

 
- debug: var=item
    with_items
:
   
- "{{tmpvar.split()}}"

Maybe there is an better way?


четверг, 13 ноября 2014 г., 11:56:34 UTC+3 пользователь Александр Лозовской написал:

Michael DeHaan

unread,
Nov 17, 2014, 4:16:03 PM11/17/14
to ansible...@googlegroups.com
Generally ansible frowns upon usages that are too "code-like" and tries to find some other ways to solve them that are easier to read.

Can we talk about your underlying use case that you are trying to model, to suggest an alternative, easier approach?



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/247122dc-e8b5-4049-b433-9e6a0baccdc6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages