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
Just in case it helps someone: I had the same error message in a slightly different case than the OP. I wrote by mistake
- name: ...
ansible.builtin.block:
- ...
- ...
But block is a primitive, not a module. It should be instead
- name: ...
block:
- ...
- ...
The error message was rather confusing.
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