Chef question on copying files from file_cache_dir into correct location


#1

Hi,

We have recently started looking at using Chef and I just wanted to get some community advice around the correct ‘Chef’ way to copy files…

In particular, we want to be able to ‘pre-load’ some larger files (jar files, some other archive types, etc) into the Chef file cache so they are already present when our image is booted, which then need to be moved/copied out to the correct location. This is mostly to speed up initial Chef runs so we don’t need to wait for the files to download over a slow link.

We currently use the remote_file resource for this, but either we specify the correct location in which case it ignores the file that already exists in our cache path (and re-downloads slowly), or we specify the cache location and then use a bash block afterwards to move or copy the file to it’s final location which doesn’t seem very ‘elegant’… Is there a better way ?

Regards,
Michael Ward.


#2

Ohai,

I’ve ended up adding helper cookbook that injects pre-downloaded package to cache folder:

Hope to see here more elegant solutions.


Roman B


Roman B

On Wednesday, 19 June, 2013 at 6:49 AM, Michael Ward wrote:

Hi,

We have recently started looking at using Chef and I just wanted to get some community advice around the correct ‘Chef’ way to copy files…

In particular, we want to be able to ‘pre-load’ some larger files (jar files, some other archive types, etc) into the Chef file cache so they are already present when our image is booted, which then need to be moved/copied out to the correct location. This is mostly to speed up initial Chef runs so we don’t need to wait for the files to download over a slow link.

We currently use the remote_file resource for this, but either we specify the correct location in which case it ignores the file that already exists in our cache path (and re-downloads slowly), or we specify the cache location and then use a bash block afterwards to move or copy the file to it’s final location which doesn’t seem very ‘elegant’… Is there a better way ?

Regards,
Michael Ward.