Search code examples
chef-infrachef-recipe

Copying zip file from remote machine to a remote machine using chef


I am trying to copy a zip file of whose path i want to give in my source attribute of remote_file or cookbook_file resource. But when i give the path it gives an error IPADDR:PORT/xyz/abc/a.txt" is not a valid source parameter for remote_file. source must be an absolute URI or an array of URIs . I wanted to know is there a way to give username and password along with the source??? I achieved this by keeping the file at the apache's root folder /var/www/ and then used the https protocol but i wish to achieve this when i have a file located at any location.


Solution

  • To access a remote file using chef resource remote_file, that file have to be accessible from the local machine with a valid URI. Knowing whis, I think you have two possible implementations:

    1. Share the file with the protocol you wish. You can use http (using a web server); you can use ftp, you can use nfs, you can use samba... Most of these sharing protocols let the authentication, so you can control the access to the file.

    2. Yo can copy the file using scp. There is a clever implementation of this in this question. If you want to avoid having the sensible information in your recipe, I would recommend manage that information using encrypted databags.