Chef/Correctness/ServiceResource
The Cookstyle cops department: Chef/Correctness
| Enabled by default | Supports autocorrection | Target Chef Version |
|---|---|---|
| Enabled | No | All 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
| Name | Default value | Configurable values |
|---|---|---|
| Version Added | 5.0.0 | String |
| Include | Array |