Is there a way to tell chef-client not to store chef cache files in the backup path (E.g. for windows C:\chef\backup\chef\cache)
My use case: I am downloading a file into Chef::Config[:file_cache_path] with a powershell_script resource that’s utilizing Read-S3Object cmdlet (not sure whether the actual resource makes a difference or not…) and then using file resource to delete the file in the Chef::Config[:file_cache_path], however the file in the backup folder above obviously persists.
Do I have to explicitly delete it from the backup path as well or is there another mechanism that’s more implicit?
Have you looked at the remote_file resource instead of using a powershell
script to download a file? The reason I bring this up is because with this
resource you can specify whether or not you would like to keep any backups
of this file, plus makes it idempotent, unless you have something in your
powershell script that already does this for you.
Hello Roberto, thank you for the reply. In my use case the source S3 object is not available via http://, I need to pass explicit iam creds to authenticate with in order to fetch it from the bucket, hence going through aws sdk. Idempotence is handled by outer logic since the script resource is within a larger custom resource. But the backup property of the remote_file that you’ve pointed out is exactly what I was looking for. So looking through remote_file source and then at the Chef::Util::Backup it sounds like I should be able to explicitly call .backup(false) on my ps script resource object? Will give that a shot.
There also is the artifact-cookbook which can download from S3. An example from the readme is:
artifact_file "/tmp/my-artifact.tgz" do
Thank you all. Will check out those cookbooks. In the meanwhile I figured out why my powershell_script’s resource_obj.backup failed for me earlier it’s because execute resource doesn’t define any accessor method for that instance var so for now I am just calling resource_obj.instance_variable_set(:@backup, false) to overwrite the default value of 5 backups. Again thanks for the tip on the backup property.