Chef/Deprecations/LegacyNotifySyntax
The Cookstyle cops department: Chef/Deprecations
Enabled by default | Supports autocorrection | Target Chef Version |
---|---|---|
Enabled | Yes | All Versions |
Use the new-style notification syntax which allows you to notify resources defined later in a recipe or resource.
Examples
incorrect
template '/etc/www/configures-apache.conf' do
notifies :restart, resources(service: 'apache')
end
template '/etc/www/configures-apache.conf' do
notifies :restart, resources(service: 'apache'), :immediately
end
template '/etc/www/configures-apache.conf' do
notifies :restart, resources(service: service_name_variable), :immediately
end
template '/etc/www/configures-apache.conf' do
subscribes :restart, resources(service: service_name_variable), :immediately
end
correct
template '/etc/www/configures-apache.conf' do
notifies :restart, 'service[apache]'
end
template '/etc/www/configures-apache.conf' do
notifies :restart, 'service[apache]', :immediately
end
template '/etc/www/configures-apache.conf' do
notifies :restart, "service[#{service_name_variable}]", :immediately
end
template '/etc/www/configures-apache.conf' do
subscribes :restart, "service[#{service_name_variable}]", :immediately
end
Configurable attributes
Name | Default value | Configurable values |
---|---|---|
Version Added | 5.13.0 | String |
Include | Array |