Thank you so much, Kai. This worked perfectly!

On Sat, Jun 22, 2019 at 2:12 AM Kai Stian Olstad <
[email protected]> wrote:

> On 22.06.2019 07:40, Angel Rengifo Cancino wrote:
> > When I assign this input to a variable, I see that ansible converts them
> to
> > a list, like this:
> >
> > mydisks: |-
> >    100
> >    20
> >    130
> >    230
> >
> > By using vmware_guest module, I'd like to convert it to something like...
> >
> > vmware_guest:
> >    disk:
> >      - size_gb: 100
> >        type: None
> >      - size_gb: 20
> >        type: None
> >      - size_gb: 130
> >        type: None
> >      - size_gb: 230
> >        type: None
> >
> > So I found some references on Internet that look like this jinja2
> > expressions:
> >
> > vmware_guest:
> >    disk: >-
> >      [{% for size in mydisks.split() %}'{ size_gb: {{ size }}, type: None
> > }', {% endfor %}]
> >
> > However, when I run the playbook I got an ugly error like this:
>
> <snip />
> >
> > Would someone, please, help me with this issue? I'm sure my jinja2
> > expression it's wrong, but I can figure out what's the right way to do
> it.
>
> With set_fact you can do this
>
> - set_fact:
>     disk: "{{ disk | default([]) + [{ 'size_gb': item, 'type': 'None' }]
> }}"
>   with_items: '{{ mydisks.split() }}'
>
>
> --
> Kai Stian Olstad
>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/568505ab-e33f-ddef-675a-ccdfc2801d60%40olstad.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAA3McK9659UdpYJzrP6uHxrxXT-qhtc2cOqzmqoB1OVEqb%2BxfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to