For my current problem I'm using the nginx
cookbook. What I want to do is to install it from source (no problem to do that using nginx::source
) and prefix it to /opt/nginx/<version>/
, but it will always be prefixed (by default) to /opt/nginx-<version>/
.
This is my ./attributes/default.rb
:
node.override['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
#also tested
override['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
#and also
default['nginx']['source']['prefix'] = "/opt/nginx/#{node['nginx']['source']['version']}"
What am I not understanding?
Thanks
An additional thing would be:
- How may I prefix it like above and create a sym-link to /opt/nginx/current
(and do that even after update)?
So, this is a shortcoming in the cookbook. Many variables are being built based on the value of that one attribute, and if you haven't set your override value FIRST, then the values in the cookbook will still win for the derived attributes.
If you set an override on the node or environment for nginx['source']['prefix']
that should work, but it's not ideal. Alternately, also override the derived values.
https://github.com/miketheman/nginx/blob/master/attributes/source.rb
default['nginx']['source']['sbin_path'] = "#{node['nginx']['source']['prefix']}/sbin/nginx"
default['nginx']['source']['default_configure_flags'] = %W(
--prefix=#{node['nginx']['source']['prefix']} # <= this one needs overridden
--conf-path=#{node['nginx']['dir']}/nginx.conf
--sbin-path=#{node['nginx']['source']['sbin_path']}
)
There may be others, but those are the two I know of, and that stand out.