Search code examples
windowschef-infrachef-recipecookbookrecipe

Where should I put an msi file in my cookbook?


I am removing a windows program by using the MSI with the windows_package resource:

windows_package 'SomeShittyProgram' do
  action :remove
  source 'c:\temp\msi'
end

Is it safe to have a (small) MSI file in my cookbook? How can I have chef deliver that file to the node?

I'd use remote_file to pull it from a network location, but that makes testing the cookbook in test kitchen difficult.


Solution

  • In general we strongly recommend against doing this (storing large binary files in a cookbook), but you can do it. Put the file under ./files/whatever.msi and then in recipe code use cookbook_file "#{Chef::Config[:file_cache_path]}/whatever.msi" do source "whatever.msi" end and then use a windows_package resource to do the install.

    The reason to not do this is that Chef is not a good file storage system. Using something like S3, Artifactory, or even an HTTP server plus remote_file gives you a lot more flexibility. This tends to rapidly bloat your git repo.