Skip to content

Commit

Permalink
Separated source version attribute from OHAI plugin version attribute…
Browse files Browse the repository at this point in the history
…. That way, updating the version number either via a set or an override attribute will force nginx recompilation
  • Loading branch information
priestjim committed Mar 6, 2013
1 parent aef8b78 commit 0629f88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion attributes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
]

default['nginx']['configure_flags'] = Array.new
default['nginx']['source']['url'] = "http://nginx.org/download/nginx-#{node['nginx']['version']}.tar.gz"
default['nginx']['source']['version'] = node['nginx']['version']
default['nginx']['source']['url'] = "http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"
default['nginx']['source']['checksum'] = "0510af71adac4b90484ac8caf3b8bd519a0f7126250c2799554d7a751a2db388"
default['nginx']['source']['modules'] = [
"http_ssl_module",
Expand Down
8 changes: 4 additions & 4 deletions recipes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
node.load_attribute_by_short_filename('source', 'nginx') if node.respond_to?(:load_attribute_by_short_filename)

nginx_url = node['nginx']['source']['url'] ||
"http://nginx.org/download/nginx-#{node['nginx']['version']}.tar.gz"
"http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"

node.set['nginx']['binary'] = node['nginx']['source']['sbin_path']
node.set['nginx']['daemon_disable'] = true
Expand All @@ -42,7 +42,7 @@
include_recipe "nginx::commons_script"
include_recipe "build-essential"

src_filepath = "#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['version']}.tar.gz"
src_filepath = "#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['source']['version']}.tar.gz"
packages = value_for_platform(
["centos","redhat","fedora","amazon","scientific"] => {'default' => ['pcre-devel', 'openssl-devel']},
"gentoo" => {"default" => []},
Expand Down Expand Up @@ -160,15 +160,15 @@
cwd ::File.dirname(src_filepath)
code <<-EOH
tar zxf #{::File.basename(src_filepath)} -C #{::File.dirname(src_filepath)} &&
cd nginx-#{node['nginx']['version']} &&
cd nginx-#{node['nginx']['source']['version']} &&
./configure #{node.run_state['nginx_configure_flags'].join(" ")} &&
make && make install
EOH

not_if do
nginx_force_recompile == false &&
node.automatic_attrs['nginx'] &&
node.automatic_attrs['nginx']['version'] == node['nginx']['version'] &&
node.automatic_attrs['nginx']['version'] == node['nginx']['source']['version'] &&
node.automatic_attrs['nginx']['configure_arguments'].sort == configure_flags.sort
end

Expand Down

0 comments on commit 0629f88

Please sign in to comment.