LegacyNotifySyntax
The department is: Chef/Deprecations
The full name of the cop is: Chef/Deprecations/LegacyNotifySyntax
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 | Exclude |
|
Array |
Was this page helpful?