Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR! 'file' is not a valid attribute for a Play [duplicate]

Tags:

ansible

new playbook test is not working. Newbie to ansible but have read throuugh the docs , samples etc. What is wrong ? ERROR! 'file' is not a valid attribute for a Play

The error appears to have been in '/home/NTNET/mresnick/testdel.yml': line 10, column 3, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- file: "path=/tmp/{{ item }} state=absent recurse=no"
  ^ here


---
- name: test playbooktestdel
- hosts: temp3
  tasks:
- name: "delete old files Aveksa"
- file: path=/tmp/{{ item }} state=absent recurse=no
  with_items:
    - { Aveksa.tar }
    - { sudo_commands }
    - { baz }
...
like image 409
MR_Expert Avatar asked Jul 28 '16 09:07

MR_Expert


1 Answers

You wrote a tasklist and tried to run it as a playbook.

When you have a playbook, you can have a tasks key in a given play, and list your preferred task there.

---

- hosts: your hosts
  tasks:
    - name: delete sg
      file:
        path: "/tmp/{{ item }}"
        state: absent
        recurse: no

...
like image 101
masu Avatar answered Nov 06 '22 11:11

masu