【问题标题】:ERROR! 'file' is not a valid attribute for a Play [duplicate]错误! “文件”不是播放的有效属性[重复]
【发布时间】:2016-07-28 09:22:18
【问题描述】:

新的剧本测试不起作用。 ansible 的新手,但已经阅读过文档、示例等。 怎么了 ? ERROR! 'file' is not a valid attribute for a Play

错误似乎出现在'/home/NTNET/mresnick/testdel.yml':第 10 行第 3 列,但可能 根据确切的语法问题,位于文件中的其他位置。

违规行似乎是:

- file: "path=/tmp/{{ item }} state=absent recurse=no"
  ^ here


---
- name: test playbooktestdel
- hosts: temp3
  tasks:
- name: "delete old files Aveksa"
- file: path=/tmp/{{ item }} state=absent recurse=no
  with_items:
    - { Aveksa.tar }
    - { sudo_commands }
    - { baz }
...

【问题讨论】:

  • yml 的更正副本:--- - 名称:测试 playbooktestdel - 主机:temp3 任务:- 名称:“删除旧文件 Aveksa” - 文件:路径=/tmp/{{ item }} 状态=absent recurse=no with_items: - { Aveksa.tar } - { sudo_commands } - { baz } ...

标签: ansible


【解决方案1】:

您编写了一个任务列表并尝试将其作为剧本运行。

当您有剧本时,您可以在给定剧本中使用tasks 键,并在其中列出您喜欢的任务。

---

- hosts: your hosts
  tasks:
    - name: delete sg
      file:
        path: "/tmp/{{ item }}"
        state: absent
        recurse: no

...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 2017-01-09
    • 1970-01-01
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    • 2011-10-29
    相关资源
    最近更新 更多