这个问题在这里已经有了答案:
ERROR! 'fail' is not a valid attribute for a Play
(1 个回答)
ERROR! 'file' is not a valid attribute for a Play [duplicate]
(1 个回答)
Ansible error stating: 'apt_repository' is not a valid attribute for a Play [duplicate]
(2 个回答)
3年前关闭。
我只是想写一个基本的剧本,并不断收到以下错误。
尝试了很多东西,但仍然无法解决问题。我知道这一定是语法问题,但不知道在哪里。
这是我的代码:
---
# This playbook runs a basic DF command.
- hosts: nagios
#remote_user: root
tasks:
- name: find disk space available.
command: df -hPT
这是我得到的错误:
> ERROR! 'command' is not a valid attribute for a Play
>
> The error appears to have been in '/root/playbooks/df.yml': line 4,
> column 3, but may be elsewhere in the file depending on the exact
> syntax problem.
>
> The offending line appears to be:
>
>
> - hosts: nagios
^ here
Ansible 版本:2.4.2.0
它让我发疯。我查看了 Ansible 文档中的一些示例,它看起来是一样的。
不知道...
有人知道吗?
最佳答案
问题是没有命令行的缩进,命令指令是整个游戏的一部分,而不是任务块。即命令应该是任务块的一部分。
---
# This playbook runs a basic DF command.
- hosts: nagios
#remote_user: root
tasks:
- name: find disk space available.
command: df -hPT
关于Ansible Playbook : ERROR! 'command' 不是 Play 的有效属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49246837/