How to download a tar file from Artifactory using Chef?

Hi All,

I am new to Chef, forgive me if this is an illogical question.

My code deployment flow is, Check in the code to bitbucket, kicks off Jenkins which will create a tar file out of that change & then put it to artifactory(Jfrog). The part which I miss is on how to use Chef to download the tar file from artifactory & then deploy it to an AIX box.

Any suggestions would be highly appreciated. Thanks in advance.

a basic remote_file resource usually does the trick:

    auth = "Basic #{Base64.encode64("#{user}:#{password}"
    remote_file ze_file do
      source "https://artifactory.your_org.tld/#{ze_path}"
      headers('Authorization' => auth)
      *snip*
      action :create
    end

Adjust for your Artifactory configuration ofc but there's little more to it than that. If you ever need anything fancier Chef also maintains a rubygem for Artifactory that you could wrap in a Chef custom resource, but the above snippet covers most people's needs.

Just a piece of additional advice for bobchaos's solution. Use tokens with expiration time for better security.

1 Like