我有以下yml:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns: 40
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"
我在standalonedb_host
行上遇到语法错误。我做错了什么?
编辑:奇怪的是,如果我对standalonedb
变量进行去缩进,则错误就会消失。如果我再次添加空格,则返回错误。
答案 0 :(得分:1)
问题是你有一个键/值对嵌套在键/值对下,即standalonedb_host: myhost0001.ab-xy.aws.com
(standalonedb_*
配置的其余部分)嵌套在maxconns: 40
下。< / p>
根据您的配置,以下任一项都可以解决问题:
删除嵌套:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns: 40
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"
删除maxconns
中的值,以便standalonedb_*
相关的哈希值成为maxconns
键的值:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns:
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"