Running the Following Playbook syntax appears to be correct but getting following ERROR!- 'blockinfile' is not a valid attribute for a Play

Deadly 提交于 2019-12-12 14:46:08

问题


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

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        

By the way I am using Ansible Version 2.x


回答1:


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


来源:https://stackoverflow.com/questions/36468870/running-the-following-playbook-syntax-appears-to-be-correct-but-getting-followin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!