Ansible fact with dot, how to escape?

Hi,

i’m trying to get the values of a fact with a dot.

For example this interface:

“ansible_bond0.247”: {
“active”: true,
“device”: “bond0.247”,

{{ ansible_bond0.247.device }}

doesn’t work, because ansible thinks that 247 is a subfact.

Any ideas how to do it?

Thanks :slight_smile:
Nils

{{ ansible_bond0.247.device }}

doesn't work, because ansible thinks that 247 is a subfact.

Use the longer (but less hinky) Python style specification:

  {{ ansible_bond0['bond0.247']['device'] }}

That also lets you differentiate between literals (like bond0.247) and
variables (e.g. if you had the interface name in a variable like
my_int_name, you could do ansible_bond0[my_int_name]['device'] and get the
right thing), if you ever need to do that.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.