Reputation: 481
eg.
The directory structure of the recipes is as follows:
--my_cookbook
|-- recipes
|- abc.rb
|- xyz.rb
|-- attributes
|-- templates
|- random.xml.erb
|-- test
Now let's assume we have a resource as follows in 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
Now we have the declaration of vicious_service
which is as follows:
service 'vicious_service' do
action [:enable, :start]
end
The question now is, Can we have the declaration of vicious_service somewhere in xyz.rb
? Or is it mandatory for us to declare it in abc.rb
?
Upvotes: 0
Views: 27
Reputation: 54267
Yes, what recipe things are in doesn't matter to Chef beyond the original loading phase. Everything ends up in a big array called the "resource collection". You can find more details at https://coderanger.net/two-pass/.
Upvotes: 1