Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

Tags:

ansible

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
like image 393
Manoj Kumar Padarthi Avatar asked Nov 23 '25 06:11

Manoj Kumar Padarthi


1 Answers

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.

like image 156
Petr Avatar answered Nov 24 '25 21:11

Petr