puppet-archive
puppet-archive copied to clipboard
Cannot clean up unless 'creates' is specified.
It appears that the archive file will not be cleaned up unless the 'creates' parameter is used AND the file that is specified by that parameter exists after extraction.
I think it would be useful to be able to cleanup even if this parameter is not specified or does not seem to exist. Is there reasoning behind not doing this?
As a workaround it is possible to specify the downloaded archive as the file used for the create parameter.
That's a good workaround that I was not aware of. This does help me in one scenario that I have. However, consider the following scenario:
I use the archive type to retrieve and extract an archive to install some software. The software is extracted to a temporary directory. Later an 'exec', or other provider, is run to install software from that temporary directory. I'd like to utilize the archive provider's 'creates' parameter to point to a file which WILL exist after this other provider runs but not immediately after the archive provider runs. In this way we can get idempotency out of the archive provider. Using the creates parameter in this way does, in fact work, but the down side is that the archive file does not get cleaned up.
While this is probably an edge case I think being able to clean up the archive file without having a valid 'creates' file configured makes general sense.
I agree with you, this is just a workaround if you really need this functionality now.
I noticed today that, if a checksum is provided, and the downloaded archive file (stored in the C:\Windows\Temp folder) doesn't match that checksum, cleanup likewise fails to happen.
This resulted in completely filling the O/S disk of several of our test VM's. Worse, since the tempfile name is randomly-generated, I can't simply follow up with a File { $tempfile: ensure => absent }
@ljkimmel -- Your second scenario may be alleviated by adding a custom extract command to the archive resource, instead of using a separate exec.
That said, this bug has been open for over four years; it's high time to fix it. I will dig into the code and see what I can do...
I have permission to spend some workhours to remediate the following:
- If the checksum does not match, the randomly-named temporary file is not deleted, regardless of the "cleanup" parameter setting.
- If the extract command fails, the downloaded archive file is not deleted, regardless of the "cleanup" parameter setting.
Once I have code that works for my employer, I will try to extract a general solution and submit a PR back to the project.