【发布时间】:2020-06-11 18:40:04
【问题描述】:
我正在尝试从 ansible 文档复制第一个 with_item 示例,但我遇到了这个错误:
fatal: [user@my-vm]: FAILED! => {"msg": "The task includes an option with an undefined variable.
The error was: 'item' is undefined\n\nThe error appears to be in 'path/ansible/playbooks/android-dev.yml': line 4,
column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\n
The offending line appears to be:\n\n tasks:\n - name: Debugging with items\n ^ here\n"}
我的代码是:
- hosts: test
tasks:
- name: Debugging with items
debug:
msg: "An item: {{ item }}"
with_items:
- 1
- 2
- 3
我正在按照此页面的第一个示例来构建任务:https://docs.ansible.com/ansible/latest/plugins/lookup/items.html
我现在已经开始使用ansible了,这可能是一个很容易解决的问题,但是我真的在网上找不到任何解决方案
【问题讨论】:
-
您的 with_items 需要处于调试状态,而不是带有 YAML 位置问题的 msg
标签: ansible