Skip to main content

ExecuteSysctl

All Cookstyle Cops


The department is: Chef/Modernize

The full name of the cop is: Chef/Modernize/ExecuteSysctl


Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNo14.0+

Chef Infra Client 14.0 and later includes a sysctl resource that should be used to idempotently load sysctl values instead of templating files and using execute to load them.

Examples

incorrect

file '/etc/sysctl.d/ipv4.conf' do
  notifies :run, 'execute[sysctl -p /etc/sysctl.d/ipv4.conf]', :immediately
  content '9000 65500'
end

execute 'sysctl -p /etc/sysctl.d/ipv4.conf' do
  action :nothing
end

correct

sysctl 'net.ipv4.ip_local_port_range' do
  value '9000 65500'
end

Configurable attributes

NameDefault valueConfigurable values
Version Added5.18.0String
Exclude
  • **/metadata.rb
  • **/attributes/*.rb
  • **/Berksfile
Array

Was this page helpful?