[chef] Libraries being used in templates.


Chronological Thread 
  • From: Scott Likens <scott@likens.us>
  • To: chef@lists.opscode.com
  • Subject: [chef] Libraries being used in templates.
  • Date: Thu, 23 Jul 2009 22:54:50 -0700

Hello all,

I had recently dug myself into using libraries and wondered if anyone had a way to make it work in templates?

I was looking at http://wiki.opscode.com/display/chef/Libraries and noticed it did not mention the word templates,

so I whipped up something like this,

all_vhosts do |name, info|
  template "/etc/nginx/sites-available/#{name}.conf" do
  source "default-site.erb"
  owner "www-data"
  group "www-data"
  mode 0644
  variables(
    name => name
  )
  end
end

I can't seem to obviously get name to iterate properly? (not sure if that's the right word) but @name never appears in the template, as a simple <%= @name %> shows zilch.

Obviously this works super clean and awesome in 1/2 of my recipe, but I was wondering if anyone had any thoughts on the last part of this hurdle? I'm sure it's something I've overlooked but I'd love a hint/ pointer/etc?

Thanks

Sincerely,

Scott M. Likens



Archive powered by MHonArc 2.6.16.

§