我正在尝试将“elasticsearch / cookbook-elasticsearch”食谱用于我的包装食谱。我想在我的包装食谱中覆盖cookbook-elasticsearch中的以下默认属性。
default.elasticsearch[:rpm_url] = "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.12.noarch.rpm"
default.elasticsearch[:rpm_sha] = "ab7ea2e00d8f1b73642e3ea44d9647b11e6b0b96"
食谱:https://github.com/elasticsearch/cookbook-elasticsearch
如何在我的Elasticsearch食谱中进行此操作?
cat site-cookbooks / my-elasticsearch / attributes / default.rb
override.elasticsearch[:rpm_url] = "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.noarch.rpm"
override.elasticsearch[:rpm_sha] = "ec8b41c54a6d897479645b2507476e0824bc71db"
这是正确的吗?
我想把这本食谱用于厨师10
任何帮助
最佳答案
要将信息添加到@ mark-oconnor注释:
Documentation about attributes in chef 10。
推荐的符号为override['elasticsearch']['rpm_url'] = "new_value"
,过去访问属性的方法和符号方式一直存在问题。
由于厨师10中的菜谱加载顺序并非总是可以明确预测的,因此您必须使用override
级别来确保在编写食谱时使用正确的值。
评论后编辑:
在0.3.13版的Elasticsearch食谱中,默认配方是从tarball安装的。
如果您希望使用打包安装,则必须在默认设置之前调用相应的配方,因为在默认配方中,如果已经安装了Elasticsearch,请不要安装tarball。
包装菜谱中针对此特定情况的正确配方是:
include_recipe 'elasticsearch::rpm' # Take the overriden attributes and install package
include_recipe 'elasticsearch' # no need to ::default, if omitted it's the recipe loaded
关于elasticsearch - 覆盖Elasticsearch Recipe 中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684778/