Ansible include_任务给出语法错误

Ansible include_任务给出语法错误,ansible,ansible-2.x,ansible-api,Ansible,Ansible 2.x,Ansible Api,Ansible版本:2.9 剧本 --- - { include_tasks: test.yml } 错误 The error appears to have been in '/path/to/main.yml': line 34, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - { include_t

Ansible版本:2.9

剧本

---
- { include_tasks: test.yml }
错误

The error appears to have been in '/path/to/main.yml': line 34, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- { include_tasks: test.yml}
  ^ here
'}}

和这个战斗了几天!请营救。

你发布的不是剧本。您需要列出主机和任务:

---
- hosts: all
  tasks:
  - include_tasks: test.yml

=>
-包含任务:test.yml
这也可能会失败,但我确信这是因为其他原因。。。你必须解决的问题
yamlint
ansible lint
可能会在这项任务中帮助您。如果您确实想使用内联语法(即使我不知道为什么),可以使用:
-{hosts:all,tasks:[{include_tasks:test.yml}]}