0

I've got two lists of dictionaries, with each key two common keys.

I'd like to have the union of this list, what is the prettier way to do so?

Input:

L1= [ { "k1": "1", "k2': "2", "v": "b" },
      { "k1": "3", "k2': "4", "v": "a" } ]

L2 = [ { "k1": "3", "k2": "4", "v2": "Z" } ]

Expected results:

L = [ { "k1": "3", "k2': "4", "v": "a" } ]

I've tried something like:

- name: list installed pkg in files list
  set_fact:
    pdt_installed_pkg: "{{ pdt_installed_pkg + installed_pkg|json_query(\"results[?name=='\" + item.name + \"' && version=='\" + item.version + \"']\") }}"
  with_items: "{{ packages }}"
kenlukas
  • 3,616
  • 9
  • 25
  • 36
Raoul Debaze
  • 466
  • 1
  • 8
  • 24

0 Answers0