Ansible返回“任务中未检测到任何动作”

时间:2019-02-06 05:13:17

标签: ansible ansible-2.x

我正在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

运行剧本时,出现错误告诉我:

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。我尝试从hosts: all中删除set-timezone.yaml,但收到此错误:“包含的任务文件必须包含任务列表”。

1 个答案:

答案 0 :(得分:0)

  

并显示以下错误:“包含的任务文件必须包含任务列表”。

正确的“任务列表”部分的确切含义是:由本身就是可完成任务的项目组成的Yaml列表:

# cat set-timezone.yaml
---
- name: this is a task
  debug: msg="hello, world"
- name: set timezone to MST
  timezone:
    name: America/Denver