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

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

Post by Anonymous »

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?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post