gpt4 book ai didi

ansible - 错误! 'file' 不是 Play 的有效属性

转载 作者:行者123 更新时间:2023-12-02 09:59:04 28 4
gpt4 key购买 nike

新的剧本测试不起作用。 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 }
...

最佳答案

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

当您有剧本时,您可以在给定剧本中拥有一个tasks键,并在其中列出您的首选任务。

---

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

...

关于ansible - 错误! 'file' 不是 Play 的有效属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38632170/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com