Hi,

in his blog entry [1], Dylan asked for feedback on the new loop feature.

As much as I understand that having a syntax with changing keywords isn't 
optimal, I dislike the new lookup-based syntax for two reasons:

   1. we've had so many issues with quoting within quoting of lookup that I 
   don't look forward having even more lookups in my code.
   2. having code within a string makes it less readable, you lose the 
   clean structure and code validation of YAML and the syntax highlighting in 
   your editor, which leads to potentially more errors.

As said, I understand that having a with_* structure in code isn't nice, 
hence I would suggest an alternative consisting of two main points:

   1. make it a clean loop structure with options
   2. merge the loop_control structure with the loop structure

This means that the following could be written instead of a with_items:

- debug:
    msg: one line of {{ myitem }}
  loop:
    with: items # instead of with_items, easier to parse hopefully
    through: # you could still use a string with fancy lookup here
      - item1
      - item2
    as: myitem # loop_var is a bit clumsy IMHO but also fine
    pause: ...etc...

or using all the (assumed) defaults:

- debug:
    msg: one line of {{ item }} # default var is still 'item'
  loop:
    through: # assuming 'items' is the default 'with'
      - item1
      - item2

This is just a suggestion as basis for discussion, and I can definitely 
live with an alternative syntax, but it should avoid having too much placed 
in strings and strings within strings, which is implied IMHO by the plain 
lookup-syntax.

KR, Eric

[1] https://www.ansible.com/blog/loop-plays-past-present-future

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/360fcca3-b763-4d99-91f6-19e4d100203d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to