Ansible 运行以下Playbook语法似乎是正确的,但出现以下错误!-';Blockinfle';不是游戏的有效属性
运行以下Playbook语法似乎是正确的,但出现以下错误!-Ansible 运行以下Playbook语法似乎是正确的,但出现以下错误!-';Blockinfle';不是游戏的有效属性,ansible,ansible-playbook,ansible-2.x,Ansible,Ansible Playbook,Ansible 2.x,运行以下Playbook语法似乎是正确的,但出现以下错误!- 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
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
我的剧本文件代码是:
---
- 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版您的剧本缺少
任务
。正如错误所说,blockinfle
在剧本中不是有效属性。你的剧本应该是这样的。举个例子,不要使用这个代码
- 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
该错误是由于您的剧本中缺少主机和任务造成的我收到了类似的错误:“uri”不是剧本的有效属性。你能帮忙吗?
-bash-4.2$ cat getUri.yml
---
- name: test playbook
hosts: localhost
tasks:
- name: Check that you can connect (GET) to a page and it returns a status 200
uri:
url: http://www.example.com