Skip to main content

Chef/Correctness/ServiceResource

Cookstyle cops page

The Cookstyle cops department: Chef/Correctness

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNoAll Versions

Use the service resource to manage services instead of shelling out. The resource is idempotent, picks the right init system for the platform, and reports correctly on what it changed. A shelled out command runs on every converge whether or not anything needed to change, so the run reports the resource as updated every time.

Examples

# bad
execute 'restart apache' do
  command 'systemctl restart httpd'
end

execute '/etc/init.d/httpd start'

# good
service 'httpd' do
  action :restart
end

Configurable attributes

NameDefault valueConfigurable values
Version Added5.0.0String
Include
    Array

    Thank you for your feedback!

    ×