【问题标题】:How do I resolve an error in my yaml file?如何解决我的 yaml 文件中的错误?
【发布时间】:2020-07-20 16:27:38
【问题描述】:

我正在尝试使用 ansible playbook 在节点上安装 docker,但我不断收到错误消息。这是剧本

---
- host: all
  become: yes
  become_user: root
  tasks:
  - name Add Docker GPG key
    apt_key: url=https://download.docker.com/linux/ubuntu/gpg

  - name: Add Docker APT repository
    apt_repository:
      repo: deb [arch=and64] https://download.docker.com/linux/ubuntu {{ansible_distributionrelease}} stable

  - name: Install list of packages
    apt:
      name: "{{item}}"
      state: installed
      update_cache: yes
    with_items:
      - apt-transport-https
      - ca-certificates
      - curl
      - software-properties-common
      - docker-ce

这是错误信息

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: No JSON object could be decoded

Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to be in '/home/ubuntu/docker.yml': line 7, column 12, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  - name Add Docker GPG key
    apt_key: url=https://download.docker.com/linux/ubuntu/gpg
           ^ here

我错过了什么?

【问题讨论】:

    标签: ansible yaml


    【解决方案1】:

    我意识到我的错误。我在“名称”之后的这一行缺少一个冒号

    - name: Add Docker GPG key
    

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 2021-05-15
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      相关资源
      最近更新 更多