Ansible Playbook 语法问题

Ansible Playbook Syntax Issue

我在使用 ansible playbook 设置 AWS VPC 时遇到问题。

这是导致问题的 YML 文件片段

Outputs:
  TemplateID:
    Description: cloudonaut.io template id
    Value: vpc/vpc-2azs
  StackName:
    Description: Stack name
    Value: !Sub '${AWS::StackName}'

最后一行是出现语法错误的地方。错误是

 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available

ERROR! Syntax Error while loading YAML.


The error appears to have been in '/vagrant/Devel/chalktalk-config/chalktalk-config/cloudformation/vpc2az.yaml': line 233, column 13, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    Description: Stack name
    Value:  !Sub '${AWS::StackName}'
            ^ here

您 运行 熟悉 YAML 标记语法。有关详细信息,请参阅 What does a single exclamation mark do in YAML?

快速的答案是用双引号将 Value 变量括起来。

Value:  "!Sub '${AWS::StackName}'"