识别 ansible 字典值中重复的键值对

Identify the key value pair with duplicates in values of ansible dictionary

我有这本字典:

Ip = {'a':['one','two','three'],'b':['one','five','six'],'c':['seven','eight','nine'],'d':['five']}

我希望我的输出是这样的

Op = {'a':['one','two','three'],'b':['one','five','six'],'d':['five']}

因为它在字典中有一些共同的值,如'one'或'five',所以应该删除重复的值。

例如

    - set_fact:
        Op: "{{ Op|d({})|combine({item.key: Ip[item.key]}) }}"
      loop: "{{ Ip|dict2items }}"
      vars:
        _lists: "{{ Ip|dict2items|json_query('[].value') }}"
        _reduced: "{{ _lists|difference([item.value]) }}"
        _match: "{{ _reduced|map('intersect', item.value)|flatten }}"
      when: _match|length > 0

给予

  Op:
    a:
    - one
    - two
    - three
    b:
    - one
    - five
    - six
    d:
    - five