我继承了一个类似剧本的文件,thing.yaml
其中包含以下内容:
---
- include: one.yaml
- include: two.yaml
ansible-playbook
我通常使用one.yaml
and启动 yaml 文件two.yaml
,但thing.yaml
被拒绝:
ERROR! 'include' is not a valid attribute for a Play
The error appears to be in '.../thing.yaml': line 2, column 3, but
may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- include: one.yaml
^ here
哪个命令行会吃掉包含这样的文件?
答案1
该include
模块在 2.16 版本中已被弃用ansible
,因为
根据关键字组合,它有太多冲突的行为,并且不清楚它在每种情况下应该如何表现。针对每个案件和相关行为制定了具体的新行动。
替代方案是include_tasks
,import_tasks
和import_playbook
。 (我个人猜测是include_role
也有,但没有列出。)
答案2
你要找的是include_tasks
,不是include
。看https://docs.ansible.com/ansible/2.8/modules/include_tasks_module.html