2011年8月9日火曜日

templateに対して任意の値をセットするにはどうすればいいか?

マニュアルに書いてある
http://wiki.opscode.com/display/chef/Templates

attributeを使いたい場合

 <%= %>の間にattributeを入れる 

attribute例

 node[:fqdn] = "latte"

reciepeの中のresourceのvariablesにセットする場合
 <%= @ %>の間に変数名を入れる

resource例
template "/tmp/foo" do
  source "foo.erb"
  variables({
    :x_men => "are keen"
  })
end

サンプルtemplate

The node <%= node[:fqdn] %> thinks the x-men <%= @x_men %>
 

0 件のコメント:

コメントを投稿