2016-06-25 36 views
1

我是新來的廚師和想知道怎樣才能從屬性傳遞變量的模板:廚師 - 變量模板

我的食譜的名字是:apache

在我的屬性文件(default.rb):

default['apache']['serverpath'] = '/etc/apache2' 

在我的模板(apache.erb),我想使用這個變量:

<% @serverpath %> 

這不行,我做錯了什麼?

回答

2

您需要將variables serverpath: node['apache']['serverpath']添加到您的配方代碼中。

+0

它在哪裏添加它嗎?在recpie的頂部? – user3580316

+1

在'template'塊中。請查看[docs](https://docs.chef.io/resource_template.html)。 – StephenKing