Skip to main content

Chef/Modernize/ExecuteArchiveExtract

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNo15.0+

Use the archive_file resource built into Chef Infra Client 15+ instead of shelling out to tar or unzip. The resource extracts tar, tar.gz, tar.bz2, tar.xz, and zip archives, and it only runs when the archive is newer than what was already extracted, where the shelled out command re-extracts on every converge.

Examples

# bad
execute 'extract nginx' do
  command "tar xzf #{Chef::Config[:file_cache_path]}/nginx.tar.gz -C /opt/nginx"
end

execute 'unzip -o /tmp/app.zip -d /opt/app'

# good
archive_file 'extract nginx' do
  path "#{Chef::Config[:file_cache_path]}/nginx.tar.gz"
  destination '/opt/nginx'
end

Configurable attributes

NameDefault valueConfigurable values
Version Added9.0.0String
Include
    Array

    Thank you for your feedback!

    ×