运行 以下 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 语法似乎是正确的,但出现以下错误!-
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 文件代码是:
---
- 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
您的剧本丢失 tasks
。正如错误所说,blockinfile
不是戏剧中的有效属性。你的剧本应该是这样的。只是一个例子,不要使用这个代码。
- 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
-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
错误是由于您的剧本中缺少主机和任务
运行 以下 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 line appears to be:
---
- name: insertupdate
^ here
我的 Playbook 文件代码是:
---
- 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
您的剧本丢失 tasks
。正如错误所说,blockinfile
不是戏剧中的有效属性。你的剧本应该是这样的。只是一个例子,不要使用这个代码。
- 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
-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
错误是由于您的剧本中缺少主机和任务