【发布时间】:2017-08-21 16:36:12
【问题描述】:
git 食谱在用于下载适当版本的 url 中有错误。 url 在属性文件中设置为默认属性,所以我想我可以用静态的东西覆盖 url,但它不起作用。以下是 git 食谱中的代码:
case node['platform_family']
when 'windows'
default['git']['version'] = '2.8.1'
if node['kernel']['machine'] == 'x86_64'
default['git']['architecture'] = '64'
default['git']['checksum'] = '5e5283990cc91d1e9bd0858f8411e7d0afb70ce26e23680252fb4869288c7cfb'
else
default['git']['architecture'] = '32'
default['git']['checksum'] = '17418c2e507243b9c98db161e9e5e8041d958b93ce6078530569b8edaec6b8a4'
end
default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe'
食谱作为依赖项包含在我的 metadata.rb 文件中,并用作我的食谱中的资源。它不是运行列表的一部分。我已经尝试像这样覆盖我的角色文件中的 url
"name": "web",
"description": "Web Server Role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 300,
"splay": 60
},
"git": {
"url": "a test string"
}
},...
这不起作用,所以我尝试将它作为默认值添加到我的配方的属性文件中,当它不起作用时,我尝试了 override! 方法,但仍然不起作用。
我认为问题是由于我声明属性时属性不存在,并且它被 git 配方覆盖。
我不知道如何解决这个问题。
【问题讨论】:
-
你是否尝试将 ``default['git']['url'] 放入你的食谱文件夹的 attributes/default.rb 中?
-
是的,这在这不起作用是它目前的样子
override!['git']['url'] = 'test string'
标签: attributes chef-infra