Wie extrahiere ich Fakten mit Punkt im variablen Namen ('interface.vlan_id')?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie extrahiere ich Fakten mit Punkt im variablen Namen ('interface.vlan_id')?

by Anonymous » 02 Apr 2025, 11:10

Ich habe dieses Beispiel-Spielbuch und es funktioniert gut.

Code: Select all

- hosts: localhost
gather_facts: true
tasks:
- name: Print network interface details
debug:
msg: "{{ ansible_ens2f0.ipv4.network }}/{{ ansible_ens2f0.ipv4.netmask }}"
< /code>
Wenn ich es mit VLAN -Tag versuche (11
)

Code: Select all

- hosts: localhost
gather_facts: true
tasks:
- name: Print network interface details
debug:
msg: "{{ ansible_ens2f0.11.ipv4.network }}/{{ ansible_ens2f0.11.ipv4.netmask }}"
< /code>
Dann erhalten Sie Fehler, kurz < /p>
dict object has no element 11
< /code>
und vollständige Nachricht < /PBR /> TASK [Print network interface details] ***************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: dict object has no element 11\n\nThe error appears to have been in '/home/ubuntu/net.yml': line 4, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Print network interface details\n      ^ here\n"}
Wie verkette ich vlan_id in Variable?

Top