是否可以通过在厨师的另一个食谱中声明服务来使用通知语句?
Is it possible to use notifies statement by having a service declared in another recipe, in chef?
例如。
菜谱的目录结构如下:
--my_cookbook
|-- recipes
|- abc.rb
|- xyz.rb
|-- attributes
|-- templates
|- random.xml.erb
|-- test
现在假设我们在 abc.rb
中有如下资源
... # Line 20
template '/some_location/random.xml' do
source 'random.xml.erb'
owner 'root'
group 'root'
mode '0644'
notifies :start, 'service[vicious_service]', :immediately
end
... # Line 28
现在我们有了vicious_service
的声明如下:
service 'vicious_service' do
action [:enable, :start]
end
现在的问题是,我们可以在 xyz.rb
的某处声明 vicious_service 吗?还是我们必须在 abc.rb
中声明它?
是的,除了原始加载阶段之外,Chef 并不关心内容在什么食谱中。一切都在一个叫做 "resource collection" 的大数组中结束。您可以在 https://coderanger.net/two-pass/.
找到更多详细信息
例如。
菜谱的目录结构如下:
--my_cookbook
|-- recipes
|- abc.rb
|- xyz.rb
|-- attributes
|-- templates
|- random.xml.erb
|-- test
现在假设我们在 abc.rb
... # Line 20
template '/some_location/random.xml' do
source 'random.xml.erb'
owner 'root'
group 'root'
mode '0644'
notifies :start, 'service[vicious_service]', :immediately
end
... # Line 28
现在我们有了vicious_service
的声明如下:
service 'vicious_service' do
action [:enable, :start]
end
现在的问题是,我们可以在 xyz.rb
的某处声明 vicious_service 吗?还是我们必须在 abc.rb
中声明它?
是的,除了原始加载阶段之外,Chef 并不关心内容在什么食谱中。一切都在一个叫做 "resource collection" 的大数组中结束。您可以在 https://coderanger.net/two-pass/.
找到更多详细信息