Skip to main content

Chef/Modernize/NodeInitPackage

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

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

    Thank you for your feedback!

    ×









    Search Results