【发布时间】:2017-10-24 00:42:01
【问题描述】:
我想检查该属性的以下路径是否存在:
s3_bucket = node['elastic']['s3']['bucket']
这是json:
"elastic": {
"version": "5.4.1",
"cluster": "cluster-dev",
"node": "node1",
"host": "localhost",
"port": 9201,
"username": "elasticsearch",
"groupname": "elasticsearch",
"s3" : {
"bucket": "hello"
}
}
字段 s3 可能不存在,具体取决于环境,我想在获取属性桶之前检查一下。我该怎么做?
【问题讨论】:
-
只是ruby ;-)
-
你能举个例子吗?我正在使用厨师,但我不使用红宝石。这是厨师的错误:
chef undefined method '[]' for nil:NilClass
标签: ruby chef-infra