问题
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