When you switch from this syntax using with_items:
with_items:
- "{{ numberedvars.stdout_lines }}"
Your loop should not look the same, instead it should be:
loop: "{{ numberedvars.stdout_lines }}"
with_items does something called flattening, which will take a nested list
of lists, and flatten it. loop does not do flattening, and by using the
`-` on a new line, indicates that you are creating a list element in YAML.
I cannot necessarily answer your numbers vs characters question, without
more context.
On Tue, Aug 13, 2019 at 3:30 PM Jason Gilfoil <[email protected]> wrote:
> So I've been looking at the porting guide for 2.5 (i'm going from 2.4 to
> 2.7).
>
> I have this task that outputs a list of version numbers as strings and
> registers the output. I then loop through the registered variable using
> with_items. I've been looking at converting this to loop. I realize that
> with_items isn't deprecated (yet), but i'm just trying to be proactive.
>
> I'm running into issues with how loop iterates over register.stdout_lines
> var vs with_items.
>
> In addition, I noticed that if i register lines that start with numbers,
> instead of words, the result of with_items is different, throwing variable
> is not defined errors.
> Here's a simplified version of what i'm doing with two different sets of
> variables to illustrate the differences.
> https://pastebin.com/ai1Bu9G0
>
> So my questions are:
>
>
> - How do I convert with_items to loop when used in conjunction with a
> registered var register.stdout_lines?
> - And as a secondary question, why does with_items treat numbers vs
> characters differently?
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3cda794a-32fe-47ec-bcd9-cf12915ddc60%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3cda794a-32fe-47ec-bcd9-cf12915ddc60%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Matt Martz
@sivel
sivel.net
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9HeEL%3D69o2t-kF5-3pj%2BYxqrf6SBc1semQj8Oz2T5K%3Dw%40mail.gmail.com.