Ansible Playbook Errors – How to Troubleshoot Ansible Playbook Execution Errors

ansibleansible-playbook

I use Ansible 2.9.2 on Ubuntu Server 18.04 + Python 3.6.9. Here is a simple Ansible project: https://github.com/770715/ansible.git

If I run:

ansible-playbook -i aws_ec2.yml add-ssh-keys.yml

it works just fine but when I try to run:

ansible-playbook -i aws_ec2.yml playbook.yml

I get an error:

dev@ops:~/code/build/ansible$ ansible-playbook -i aws_ec2.yml playbook.yml
/usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.25.7) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
ERROR! unexpected parameter type in action: <class 'bool'>

The error appears to be in '/home/dev/code/build/ansible/roles/docker/tasks/main.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Install Docker
  ^ here

The YAML file syntax seems to be correct (I have checked that with a number of different validators).

urllib3 (1.25.7) and chardet (3.0.4) are in the latest versions. I'd appreciate it if you could help.

Best Answer

The format of your role is incorrect. While a playbook specifies target hosts and other material, a role is simply a list of tasks. You're getting the error because you've formatted roles/docker/tasks/main.yml like a playbook. Instead of:

- name: Install Docker
  gather_facts: No
  hosts: docker

  tasks:
    - name: Install yum utils
      yum:
        name: yum-utils
        state: latest
[...]

You should have:

- name: Install yum utils
  yum:
    name: yum-utils
    state: latest
[...]