覆盖chef资源中的属性

时间:2016-06-27 14:16:23

标签: chef chef-recipe

我为redisio community cookbook创建了一个包装器食谱,我想覆盖download_dir的{​​{1}}属性:

resources/install.rb

由于attribute :download_dir, :kind_of => String, :default => Chef::Config[:file_cache_path] 它正在运行chef-client运行的路径(/ var / chef / cache)。问题在于file_cache_path(redisio cookbook),因为只有attributes/default.rb在我指定的文件夹中创建一个bin,如下所示:

install_dir

1 个答案:

答案 0 :(得分:2)

您可以自行调用redisio_install提供商并提供download_dir选项,而不是包含install recipe,而不是{{3}}。使用

include_recipe 'redisio::_install_prereqs'
include_recipe 'build-essential::default'

redis = node['redisio']
location = "#{redis['mirror']}/#{redis['base_name']}#{redis['version']}.#{redis['artifact_type']}"

redisio_install "redis-installation" do
  version redis['version'] if redis['version']
  download_url location
  safe_install redis['safe_install']
  install_dir redis['install_dir'] if redis['install_dir']
  download_dir "/tmp"
end