Vlad Cenan
Vlad Cenan

Reputation: 172

Override an attribute in chef resource

I created a wrapper cookbook for the redisio community cookbook and I want to override download_dir attribute from resources/install.rb:

attribute :download_dir, :kind_of => String, :default => Chef::Config[:file_cache_path]

Because of file_cache_path it taking the path where chef-client is running (/var/chef/cache). The issue is that in attributes/default.rb (of the redisio cookbook), as there is only install_dir which is creating a bin in my specified folder like this:

node.override['redisio']['install_dir'] = '/redis-setup'  -> rediswrapper cookbook 

Upvotes: 0

Views: 889

Answers (1)

StephenKing
StephenKing

Reputation: 37600

Instead of including the install recipe, you could just take the important parts and call the redisio_install provider yourself and supplying the download_dir option, e.g. using

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

Upvotes: 2

Related Questions