Create a Dict key from a variable

Hi,

I hope I am using the right terminology here.
I’m trying to modify some cisco_ios facts. I know how to use combine to merge the two together. I’m having problems creating a list/dict that I can use to merge into the original dict
The playbook is passed a variable called “port”. What I would like to create a fact as below

set_fact: temp_interface: "{{ port }}": name: "{{ port }}" description: free status: shutdown

This above does not work. As an example port = GigabitEthernet1/0/10

The result from above is:

`
TASK [debug] *******************************************************************************************************************************************************************
ok: [switch-poc-sw8.gw.mcgill.ca] => {
“temp_interface”: {
“{{ port_id }}”: {
“description”: “free”,
“name”: “GigabitEthernet1/0/10”,
“status”: “shutdown”

}
}
}
`

How can this be accomplished.
Thanks

Try this

   - set_fact:
        temp_interface: "{{ temp_interface|
                            default({})|
                            combine({port: {'name': port,
                                            'description': 'free',
                                            'status': 'shutdown'}})
                                            }}"

Cheers,

  -vlado

Thanks Vladamir,

Works great!

Wish there was some good docs out there.