ansible - 如何解决我的 yaml 文件中的错误?
问题描述
我正在尝试使用 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
我错过了什么?
解决方案
我意识到我的错误。我在“名称”之后的这一行缺少一个冒号
- name: Add Docker GPG key
推荐阅读
- python - 使用 Python 从站点(例如天气预报)获取实时日期
- r - 使用 R 在另一个向量中的一个向量中的元素的位置
- corda - 如何在corda中创建带有ID的帐户
- ios - 如何在 Alamofire 5 中的 responseDecodable 中获得响应
- html - 粘性元素在 iOS Chrome 中无法正常工作
- json - 如何使用 Go 后端和 ReactJS 前端在 MongoDB 中插入 markdown 代码
- typescript - 与 webpack 捆绑后 Nestjs 应用程序无法运行
- xml - XPath 中不同的 * 选择策略
- c# - 如何在 net 5.0 中使用服务通信?
- python-3.x - 有没有一种干净的方法来访问生成器表达式的本地迭代范围?