【发布时间】:2019-02-06 05:13:16
【问题描述】:
我在 Debian Buster 上运行 ansible-playbook 版本 2.7.6+dfsg-1。我有一本包含另一本的剧本,如下所示:
---
- hosts: "{{ target }}"
tasks:
- include_tasks: set-timezone.yaml
包含的set-timezone.yaml内容如下:
---
- hosts: all
tasks:
- name: set timezone to MST
timezone:
name: America/Denver
当我运行 playbook 时,我收到一条错误消息告诉我:
no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/etc/ansible/playbooks/set-timezone.yaml': line 2, column 3, but maybe elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here
我看到一个类似的问题,其中提问者拼错了模块的名称,但我很确定“时区”拼写正确,并且根据official docs,该模块在 2.7 中。我尝试从set-timezone.yaml 中删除hosts: all,却得到了这个错误:“包含的任务文件必须包含任务列表”。
【问题讨论】:
-
你可以尝试通过从包含的播放中删除主机和任务行来运行任务,即从 set-timezone.yaml
-
是的,成功了。谢谢!
标签: ansible ansible-2.x