4

运行以下剧本语法似乎是正确的,但得到以下错误!-

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

4

2 回答 2

9

你的剧本不见了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
于 2016-04-07T12:22:45.560 回答
1
-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

该错误是由于您的剧本中缺少主机和任务

于 2020-02-19T02:40:43.740 回答