Chef/Modernize/ExecuteArchiveExtract
The Cookstyle cops department: Chef/Modernize
| Enabled by default | Supports autocorrection | Target Chef Version |
|---|---|---|
| Enabled | No | 15.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
| Name | Default value | Configurable values |
|---|---|---|
| Version Added | 9.0.0 | String |
| Include | Array |