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
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
-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
The error is due to hosts and tasks missing in your playbook
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With