运行以下Playbook语法似乎是正确的,但出现以下错误!-'blockinfile'不是Play的有效属性 [英] Running the Following Playbook syntax appears to be correct but getting following ERROR!- 'blockinfile' is not a valid attribute for a Play
本文介绍了运行以下Playbook语法似乎是正确的,但出现以下错误!-'blockinfile'不是Play的有效属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行以下Playbook语法似乎正确,但出现以下错误!-
Running the Following Playbook syntax appears to be correct but getting following ERROR!-
ERROR! 'blockinfile' is not a valid attribute for a Play
The error appears to have been in '/root/playbook1.yml': line 2, column 3, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: insertupdate
^ here
我的Playbook文件代码为:
My Playbook file code is:
---
- name: insertupdate
blockinfile:
dest: /etc/network/interfaces
block: |
iface eth2 inet static
address 192.168.0.1
netmask 255.255.255.0
通过我使用Ansible版本2.x的方式
By the way I am using Ansible Version 2.x
推荐答案
您的剧本缺少tasks
.就像错误说的那样,blockinfile
在播放中不是有效的属性.您的剧本应该是这样的.只是一个示例,请不要使用此代码.
Your playbook is missing tasks
. Like the error says, blockinfile
is not a valid attribute in a play. Your playbook should be something like this. Just an example, don't use this code.
- hosts: 127.0.0.1
tasks:
- name: insertupdate
blockinfile:
dest: /etc/network/interfaces
block: |
iface eth2 inet static
address 192.168.0.1
netmask 255.255.255.0
这篇关于运行以下Playbook语法似乎是正确的,但出现以下错误!-'blockinfile'不是Play的有效属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文