How do I resolve an error in my yaml file?

给你一囗甜甜゛ 提交于 2021-02-11 14:24:03

问题


I'm trying to install docker on a node using an ansible playbook, but I keep getting an error. Here's the playbook

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

And here's the error message

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

What am I missing?


回答1:


I realized my mistake. I was missing a colon on this line after 'name'

- name: Add Docker GPG key


来源:https://stackoverflow.com/questions/62999808/how-do-i-resolve-an-error-in-my-yaml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!