On Fri, 25 Aug 2023 06:19:39 -0700 (PDT)
jean-christophe manciot <actionmysti...@gmail.com> wrote:

> We need to remove the item ''4444444444  from the list <nic_ids> located 
> inside the dictionary matched by the key/value  net_id=='1'.

Put the items you want to update into a dictionary. For example,

    diff:
      '1': [4444444444]

Use Jinja to update the list

    update: |
      {% filter from_yaml %}
      {% for i in vpc.provider %}
      {% if i.net_id in diff %}
      {% set nic_ids=i.nic_ids|difference(diff[i.net_id]) %}
      - {{ i|combine({'nic_ids': nic_ids}) }}
      {% else %}
      - {{ i }}
      {% endif %}
      {% endfor %}
      {% endfilter %}

Then, create the dictionary

    new_vpc:
      provider: "{{ update }}"



-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20230825185728.09b6f5f9%40gmail.com.

Attachment: pgpZHIwAG1rUk.pgp
Description: OpenPGP digital signature

Reply via email to