Wednesday, December 1, 2021

Ansible - Unexpected parameter type in action

If the error "ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>" appears when running a role implies there is issue with the playbook. Mostly the playbook has been written in standalone mode and not as running inside a role. Playbook should not contain task, hosts and other parameters. Just the name of the task and the task parameters. This should fix the issue. For example, a playbook file will look like below.
---
- shell: ls -la
  register: shell_result

- debug:
    var: shell_result.stdout_lines
...
And corresponding role file is:
---
- name: list task role
  hosts: localhost
  user: root
  become: yes
  become_user: root

  roles:
    - ls
...