On 19. mai 2017 16:38, Anfield wrote:
I have the following playbook and I got the above error. This created the
directory but not the file. Any ideas?

---
- hosts: local
  tasks:
   - name: create a file if it doesnt exist
     file:
       path: /home/ansible/touchfile.txt
       state: touch
       mode: 0755
  tasks:
   - name: create a directory if it doesnt exist
     file:
       path: /home/ansible/touchdir
       state: directory
       mode: 0755


You can only have one tasks: in a play.
And as the message say only the last one will be executed.

So this is the correct syntax.
---
- hosts: local
  tasks:
    - name: create a file if it doesnt exist
      file:
        path: /home/ansible/touchfile.txt
        state: touch
        mode: 0755

    - name: create a directory if it doesnt exist
      file:
        path: /home/ansible/touchdir
        state: directory
        mode: 0755

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d1a68667-d68e-3181-1aaf-1f02e68a142d%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to