- hosts: localhost
gather_facts: true
tasks:
- name: Print network interface details
debug:
msg: "{{ ansible_ens2f0.ipv4.network }}/{{ ansible_ens2f0.ipv4.netmask }}"
< /code>
Если я попробую с тегом VLAN (11), то получение ошибки < /p>
- hosts: localhost
gather_facts: true
tasks:
- name: Print network interface details
debug:
msg: "{{ ansible_ens2f0.11.ipv4.network }}/{{ ansible_ens2f0.11.ipv4.netmask }}"
< /code>
ошибка < /p>
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"}
Как мне объединить идентификатор VLAN в переменной?
У меня есть этот образец Playbook, и он работает нормально. < /p> [code]- hosts: localhost gather_facts: true tasks: - name: Print network interface details debug: msg: "{{ ansible_ens2f0.ipv4.network }}/{{ ansible_ens2f0.ipv4.netmask }}" < /code> Если я попробую с тегом VLAN (11), то получение ошибки < /p> - hosts: localhost gather_facts: true tasks: - name: Print network interface details debug: msg: "{{ ansible_ens2f0.11.ipv4.network }}/{{ ansible_ens2f0.11.ipv4.netmask }}" < /code> ошибка < /p> 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"} [/code] Как мне объединить идентификатор VLAN в переменной?