I'm trying to build nginx files for different environments. My recipe has a hashmap like so:
domain = {
production: {
public: 'example.com',
internal: 'example.dev'
},
staging: {
public: 'examplestage.com',
internal: 'examplestage.dev'
}
}
template '/etc/nginx/conf.d/example.conf' do
source 'example.conf.erb'
variables(
:domain => domain,
)
end
In my template, I want to do something like this:
...
server <%= @domain[node.chef_environment][:public] %> <%= @domain[node.chef_environment][:public] %>;
...
I'm trying to get this to evaluate to something like this, depending on the environment the node belongs to staging
or production
:
server example.com example.dev;
The problem is that, the node.chef_environment
part does not get interpolated. How do I solve this?