Creating a var from nested facts

I need to get the speed of the default ipv4 address; unfortunately, this information is contained within multiple facts.
The default ipv4 address can be found in the “ansible_default__ipv4.interface” fact. The speed is then gathered from the “ansible_.speed” fact.

I have tried a single variable and multiple variables to gather this info. I keep getting errors.

Am I approaching this right? Do I have a syntax issue?

vars:

`
default_eth: “{{ (ansible_default_ipv4.interface) }}”
bitrate: “{{ (ansible.{{ default_eth }}.speed)|int|abs }}”

`

Also tried:

`
bitrate: “{{ (ansible.{{ansible_default_ipv4.interface}}.speed)|int|abs }}”

`

Sample Failure:

`
fatal: [ansibletest-oel6]: FAILED! => {“failed”: true, “msg”: “{{ (ansible.{{default_eth}}.speed)|int|abs }}: template error while templating string: expected name or number. String: {{ (ansible.{{default_eth}}.speed)|int|abs }}”}

`

- hosts: all
    tasks:
        - debug: 'msg="{{vars[\"ansible_\" +
          ansible_default_ipv4.interface].speed}}"'

(based partially on https://stackoverflow.com/a/33444051/1114687)

But really, we should just provide the interface information as a
dictionary, as we're already doing with disk devices…

Regards,
Nils

I've opened an issue about this, if anyone wants to chime in:
https://github.com/ansible/ansible/issues/30246

Awesome, thanks!