One way is to override it from the environments/some-env.rb file.
But I think to look its values later, I’ll have to re-map opening
individual env files.
It would be better if I could just add it in the roles file per env like
env_run_list.
Is this already in chef or any plugins?
The way we deal with it is to create a cookbook/recipe per role. So we
would introduce a cookbook named “mybiz-ftpserver”. Then have it do any of
the environment specific logic before including the relevant recipes.
Something like;
file: mybiz-ftpserver/recipes/default.rb
if node.environment == 'production’
node.override[‘vsftpd’][‘chroot_users’] = [“ftpuser”]
else
node.override[‘vsftpd’][‘chroot_users’] = [“other_ftpuser”]
end
include_recipe ‘vsftpd::default’
And then the role would look something like
roles/ftpserver.rb
name "ftpserver"
description "ftpserver"
run_list(‘mybiz-ftpserver’)
That way all the logic you want for environment specific customisation is
explicit in a cookbook and relatively easy to understand.