Skip to main content

Chef/Modernize/ExecuteUpdateAlternatives

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNo16.0+

Chef Infra Client 16.0 and later includes an alternatives resource that should be used to manage alternatives links instead of shelling out to update-alternatives or alternatives. The resource is idempotent and handles both the Debian and RHEL flavours of the command, where an execute re-runs on every converge and reports the resource as updated every time.

Examples

# bad
execute 'install java alternative' do
  command 'update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre-11/bin/java 1'
end

execute 'alternatives --set java /usr/lib/jvm/jre-11/bin/java'

# good
alternatives 'java' do
  link '/usr/bin/java'
  path '/usr/lib/jvm/jre-11/bin/java'
  priority 1
  action :install
end

Configurable attributes

NameDefault valueConfigurable values
Version Added9.0.0String
Include
    Array

    Thank you for your feedback!

    ×