Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version is hard coded so that we can't change the default version in wrap cookbooks #457

Closed
Wing924 opened this issue Aug 30, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@Wing924
Copy link
Contributor

commented Aug 30, 2017

Those codes are evaluated before wrap cookbooks, so we can't change those attributes by overwrite node['rabbitmq']['version'].

default['rabbitmq']['deb_package'] = "rabbitmq-server_#{node['rabbitmq']['version']}-1_all.deb"
default['rabbitmq']['deb_package_url'] = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/"

case node['platform_family']
when 'rhel', 'fedora'
  default['rabbitmq']['rpm_package'] = if node['platform_version'].to_i > 6
                                         "rabbitmq-server-#{node['rabbitmq']['version']}-1.el7.noarch.rpm"
                                       else
                                         "rabbitmq-server-#{node['rabbitmq']['version']}-1.el6.noarch.rpm"
                                       end
when 'suse'
  default['rabbitmq']['rpm_package'] = "rabbitmq-server-#{node['rabbitmq']['version']}-1.suse.noarch.rpm"
end

default['rabbitmq']['rpm_package_url'] = "https://www.rabbitmq.com/releases/rabbitmq-server/v#{node['rabbitmq']['version']}/"

Solutions:

Per suggestion from @yardinicwaller:

Do URL string interpolation in a recipe, while still allowing that to be overridden by an attribute if defined. It would look something like this:

attributes/default.rb:

default['rabbitmq']['version'] = '3.6.12'
default['rabbitmq']['deb_package'] = nil # override me if you have a local mirror

recipes/default.rb:

default_deb_package = "https://[base URL]/v#{node['rabbitmq']['version']}/"
deb_package = node['rabbitmq']['deb_package'] || default_deb_package
remote_file "#{Chef::Config[:file_cache_path]}/#{deb_package}" do
  source deb_package
@michaelklishin

This comment has been minimized.

Copy link
Member

commented Aug 30, 2017

@Wing924 feel free to look into a pull request that would make the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.