大网数据广告活动
服务器运维问答

Ansible gives me an error during execution of some playbooks

· 52CE 我爱测

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 ru…

问题原文

原帖链接 · Jacek · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · larsks · CC BY-SA 4.0

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
[...]

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-01-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。