Attributes 厨师覆盖烹饪书的默认属性
git cookbook用于下载相应版本的url中存在错误。url在属性文件中被设置为默认属性,所以我想我可以用一些静态的东西覆盖url,但它不起作用。以下是git cookbook中的代码:Attributes 厨师覆盖烹饪书的默认属性,attributes,chef-infra,Attributes,Chef Infra,git cookbook用于下载相应版本的url中存在错误。url在属性文件中被设置为默认属性,所以我想我可以用一些静态的东西覆盖url,但它不起作用。以下是git cookbook中的代码: case node['platform_family'] when 'windows' default['git']['version'] = '2.8.1' if node['kernel']['machine'] == 'x86_64' default['git']['architec
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'
食谱作为一个依赖项包含在my 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"
}
},...
这不起作用,所以我尝试将其作为默认值添加到配方的属性文件中,当这不起作用时,我尝试了覆盖代码>仍然不起作用的方法
我认为问题的原因是,当我声明属性时,该属性不存在,并且它被git配方覆盖
我不知道如何避开这个问题。使用覆盖属性
而不是默认属性
:
"name": "web",
"description": "Web Server Role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 300,
"splay": 60
}
},
"override_attributes": {
"git": {
"url": "a test string"
}
},...
使用覆盖\u属性
而不是默认\u属性
:
"name": "web",
"description": "Web Server Role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 300,
"splay": 60
}
},
"override_attributes": {
"git": {
"url": "a test string"
}
},...
您是否尝试将``default['git']['url']放在配方文件夹的attributes/default.rb中?是的,这不起作用,这是当前的override!['git']['url']='teststring'
您是否尝试将``default['git']['url']放在配方文件夹的attributes/default.rb中?是的,这不起作用,这就是当前的情况覆盖!['git']['url']=“测试字符串”