如何解决Yaml文件中的错误? [英] How do I resolve an error in my yaml file?

查看:241
本文介绍了如何解决Yaml文件中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这是错误消息

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

我想念什么?

推荐答案

我意识到了自己的错误.我在名称"后的这一行上缺少一个冒号

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

- name: Add Docker GPG key

这篇关于如何解决Yaml文件中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆