I have the following that is not working.
`
vars:
cmdb: xkjsdflkjsjdl4d
cisco_ios:
interfaces:
gigabit1/0/1:
name: Gigabit1/0/1
status: up
gigabit1/0/2:
name: Gigabit1/0/2
status: down
tasks:
- name: Test in loop
include: test_loop_fact2.yml
loop: “{{ cisco_ios.interfaces | dict2items }}”- debug:
var: cisco_iostest_loop_fact2**.yml:**
- name: set fact
set_fact:
new_fact:
interfaces:
“{{ item.key }}”:cmdbId: “{{ cmdb }}”
- name: merge
set_fact:
cisco_ios: “{{ cisco_ios|combine(new_fact,recursive=True) }}”
cacheable: true`
I want to be able to insert cmdbId under cisco_ios.interfaces.gigabit1/0/1 and cisco_ios.interfaces.gigabit1/0/2 but I cannot figure out how to do this. With the above I get:
`
TASK [debug] ****************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
“cisco_ios”: {
“interfaces”: {
“gigabit1/0/1”: {
“name”: “Gigabit1/0/1”,
“status”: “up”
},
“gigabit1/0/2”: {
“name”: “Gigabit1/0/2”,
“status”: “down”
},
“{{ item.key }}”: {
“cmdbId”: “xkjsdflkjsjdl4d”
}
}
}
}
`
I’ve tried removing the “{{ }}” and tried but get errors. How do I reference it.
I want to end up with
cisco_ios:
interfaces:
gigabit1/0/1:
name: Gigabit1/0/1
status: up
cmdbId: xxxxxx
gigabit1/0/2:
name: Gigabit1/0/2
status: down
cmdbId: xxxxxx