【发布时间】:2017-06-20 21:26:42
【问题描述】:
这是我要运行以创建 ec2 实例的 yml 脚本。但是无论我在第一行放什么,我都会在第一行出错。
语法检查并且没问题。
错误:
"ERROR! A malformed block was encountered.
The error appears to have been in '/root/aws-create/ec2c.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
-
name: Stage instance(s)
^ here"
-
name: Stage instance(s)
hosts: aws
connection: ssh
remote_user: ec2-user
become: yes
gather_facts: false
vars:
keypair: newrhel_2
instance_type: t2.micro
security_group: default
image: ami-b55a51cc
aws_region: us-west-2
aws_access_key: xxxxxxxxxxxxxxxxxxxxxxxx
aws_secret_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tasks:
ec2:
aws_access_key={{aws_access_key}}
aws_secret_key={{aws_secret_key}}
keypair={{keypair}}
group={{security_group}}
instance_type={{instance_type}}
image={{image}}
region={{aws_region}}
wait=true
count=1
【问题讨论】:
-
第一行的
-是干什么用的?我见过三个---表示一个 YAML 文件,但不是一个单独的。 -
@Jack 表示一个列表元素——YAML 中最基本的结构之一。剧本是剧本的清单。
-
好的——我以前从来没有单独见过一个。我会把
name:放在同一行。
标签: amazon-web-services amazon-ec2 ansible yaml