voxpupuli / puppet-archive

Compressed archive file download and extraction with native types/providers for Windows and Unix
https://forge.puppet.com/puppet/archive
Apache License 2.0
59 stars 176 forks source link

Files unpacked in `/tmp` #486

Closed hboetes closed 1 month ago

hboetes commented 1 year ago

I was getting complaints from my users that /tmp was getting full. Inspecting the system I noticed the new Matlab release attempted to be unpacked in /tmp, and that will never fit since /tmp is 2Gb

Here is the recipe I used.

  archive { '/usr/local/MATLAB-R2022a.tgz':
    ensure        => present,
    extract       => true,
    extract_path  => '/',
    source        => 'https://repo.example.com/sysadmin/MATLAB-R2022a.tgz',
    checksum      => '72ec24e98a5ca0a0da99ac955140e56e746fd052',
    checksum_type => 'sha1',
    creates       => '/usr/local/MATLAB/R2022a/',
    cleanup       => true,
  }

Now if I run puppet agent -t manually, things go fine. This is probably due to the fact I've set my $TMP to $HOME/.local/tmp, which is not only a much larger partition, but also not prone to symlink attacks.

Please make sure archive avoids unpacking in /tmp and uses the given path — /usr/local/MATLAB in this case — to unpack the files.

This will not only enable unpacking larger packages but also be more efficient since the unpacked directory is already in the right partition.

geoffrey-rodgers commented 1 month ago

Hello,

You can use the resource attribute _tempdir to override where files are temporarily unpacked, as per https://github.com/voxpupuli/puppet-archive?tab=readme-ov-file#reference, specifically:

_tempdir: Specify an alternative temporary directory to use for copying files, if unset then the operating system default will be used.

hboetes commented 1 month ago

So I added:

    temp_dir      => '/usr/local/MATLAB/',

To the recipe above as the last line and I got the following error:

Error: Could not set 'present' on ensure: no implicit conversion of nil into String (file: /etc/puppetlabs/code/modules/matlab/manifests/matlab22a.pp, line: 2)
Error: Could not set 'present' on ensure: no implicit conversion of nil into String (file: /etc/puppetlabs/code/modules/matlab/manifests/matlab22a.pp, line: 2)
Wrapped exception:
no implicit conversion of nil into String
Error: /Stage[main]/Matlab::Matlab22a/Archive[/usr/local/MATLAB-R2022a.tgz]/ensure: change from 'absent' to 'present' failed: Could not set 'present' on ensure: no implicit conversion of nil into String (file: /etc/puppetlabs/code/modules/matlab/manifests/matlab22a.pp, line: 2)

What am I missing here?