Skip to main content

NodeInitPackage

The department is: NodeInitPackage

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

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll 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

NameDefault valueConfigurable values
Version Added5.22.0String
Include
    Array

    Was this page helpful?

    ×









    Search Results