tsusanka
tsusanka

Reputation: 4841

Passing attribute to definition's template in Chef

I've installed apache2 on my virtual server using the community apache2 cookbook. Then I wanted to create virtual host and I followed these steps. In a nutshell I have a small cookbook, with recipe like this:

include_recipe "apache2"

web_app "my-site" do
  server_name "my-site.localhost"
  server_aliases ["www.my-site.localhost"]
  docroot "/vagrant"
end

and a template templates/default/web_app.conf.erb containing virtual host settings. The template contains a lot of @params[:something] variables. I would like to set the variable @params[:directory_options] to Indexes to allow file listing. How can I do that? I tried keys like params or adding something to attributes, but nothing has worked.

Upvotes: 0

Views: 382

Answers (1)

tsusanka
tsusanka

Reputation: 4841

All you have to do is use the parameter's name. The same way you set up docroot you can set the other varibles:

web_app 'vagrant' do
  server_name 'v.l'
  server_aliases ['www.v.l']
  docroot '/var/www/'
  directory_options 'FollowSymLinks Indexes'
end

Upvotes: 2

Related Questions