I have data in YAML format below
ospf_neighbors:
- data: xe-0/0/1.0
- data: Full
- data: xe-0/0/10.0
- data: Full
- data: xe-0/0/11.0
- data: Full
What I want to do is create a dictionary with basically the odds been keys and the evens been values. This is the target:
ospf_neighbors_dict:
xe-0/0/1.0: Full
xe-0/0/10.0: Full
xe-0/0/11.0: Full
- name: Create Dict Pair for OSPF neighbors
set_fact:
ospfneighbors_dict: "{{ ospfneighbors_dict|
default({})|
combine({item['data'][::2]: item['data'][1::2]}) }}"
with_items: "{{ ospf_neighbors }}"
But that is just splicing the data, e.g "Fl": "ul"