Skip to main content

NodeInitPackage

The department is: NodeInitPackage

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

Enabled by default Supports autocorrection Target Chef Version
Enabled Yes All Versions

Use node[‘init_package’] to check for systemd instead of reading the contents of ‘/proc/1/comm’

Examples

incorrect

::File.open('/proc/1/comm').gets.chomp == 'systemd'
::File.open('/proc/1/comm').chomp == 'systemd'
File.open('/proc/1/comm').gets.chomp == 'systemd'
File.open('/proc/1/comm').chomp == 'systemd'
IO.read('/proc/1/comm').chomp == 'systemd'
IO.read('/proc/1/comm').gets.chomp == 'systemd'
::IO.read('/proc/1/comm').chomp == 'systemd'
::IO.read('/proc/1/comm').gets.chomp == 'systemd'
File.exist?('/proc/1/comm') && File.open('/proc/1/comm').chomp == 'systemd'
only_if 'test -f /bin/systemctl && /bin/systemctl'

correct

node['init_package'] == 'systemd'
only_if { node['init_package'] == 'systemd' }

Configurable attributes

Name Default value Configurable values
Version Added 5.22.0 String
Include
Array

Was this page helpful?

×









Search Results