这是我想运行的yml脚本来创建ec2实例。但无论我放在那里,我都会在第一行收到错误。
语法检查并且很精细。
错误:
"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

答案 0 :(得分:1)
tasks
应包含列表,而不是字典(因为您使用Ansible表示法,ec2
无效作为YAML字典)。您需要在ec2
之前添加连字符:
tasks:
- ec2: