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