错误! “文件"不是Play的有效属性 [英] ERROR! 'file' is not a valid attribute for a Play

查看:452
本文介绍了错误! “文件"不是Play的有效属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的剧本测试无法正常工作. Ansible的新手,但已阅读了文档,示例等. 怎么了 ? ERROR! 'file' is not a valid attribute for a Play

new playbook test is not working. Newbie to ansible but have read throuugh the docs , samples etc. What is wrong ? ERROR! 'file' is not a valid attribute for a Play

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

The error appears to have been in '/home/NTNET/mresnick/testdel.yml': line 10, column 3, but may be elsewhere in the file depending on the exact syntax problem.

违规行似乎是:

- 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 }
...

推荐答案

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

You wrote a tasklist and tried to run it as a playbook.

拥有剧本时,可以在给定的剧本中使用tasks键,并在其中列出您的首选任务.

When you have a playbook, you can have a tasks key in a given play, and list your preferred task there.

---

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

...

这篇关于错误! “文件"不是Play的有效属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆