Я пытаюсь ссылаться на переменные хоста в книге воспроизведения в сочетании с "with_items".
Мой инвентарь
[container]
testcontainer-01.example.org template_name="syslog" ipv4="192.168.1.101"
testcontainer-02.example.org template_name="syslog" ipv4="192.168.1.102"
Книга воспроизведения:
tasks:
- debug:
var: "{{ item.ipv4 }}"
with_items:
- "{{ groups['container'] }}"
Всякий раз, когда я запускаю воспроизведение, я получаю следующую ошибку:
The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'ipv4'
Когда я запрашиваю отладку только для {{ item }}
, без атрибута ipv4 он просто говорит, что переменная не определена.
"testcontainer-01.example.org ": "VARIABLE IS NOT DEFINED!: Unable to look up a name or access an attribute in template string ({{testcontainer-01.example.org}}).\nMake sure your variable name does not contain invalid characters like '-': unsupported operand type(s) for -: 'StrictUndefined' and 'StrictUndefined'"