I was asked to create a simpefile.txt if does not exist in the directory
so I created a directory first using Adhoc command then using playbook I created this:
---
- hosts: all
become: true
tasks:
- name: check for file
stat: path=/home/user/test/simplefile.txt
register: stat_result
- name: copy file
file: path=/home/user/test/simplefile.txt state=touch
when: not stat_result.stat.exists
But getting an error:
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>
The error appears to be in '/projects/challenge/fresco_when/tasks/main.yml': line 2, column 3, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here