I have seen several examples of installing windows apps using the Chef Git resource. I have two questions about this:
What is the best practice for installing windows applications that are not made available in Git and don't have existing cookbooks in the Chef community?
e.g. download and install a Windows installer hosted @ a static URL? I suppose I could just host it in a git repo and pull it down, but wondering if there is a more elegant way to pull it directly from the providers site similar to wget?
How does one run the windows installer once downloaded, and provide the parameters requested during the install routine? e.g. what is the windows no compile equivalent of :run, "bash[compile_app_name]", and how does one include the parameters required by the install utility (install dir, etc.) in the chef Recipe?
The Windows cookbook does include a windows_package LWRP. The documentation includes several examples, including how to install from a URL.
However, I've found that in some cases, it doesn't always work well. For example, the uninstall process sometimes fails.
In my cookbook, I used a home-cooked recipe. It's not perfect, but it gives you some control of the download and install process.
(1) Define (or reuse) a download mechanism
def download_from_ftp package
ftp_info = data_bag_item(node.chef_environment, 'ftp-credentials')['credentials']['ftp']
ftp_file_path="/#{package}"
target = "#{node['downloads']}/#{package}"
remote_file "#{target}" do
source "ftp://#{ftp_info['user']}:#{ftp_info['password']}@#{ftp_info['host']}/#{ftp_file_path}"
action :create_if_missing
end
target
end
(2) Create the :install action
action :install do
package = "#{new_resource.name}_#{new_resource.build}.exe"
location = download_from_ftp(package)
execute "install #{new_resource.name}" do
command "call #{location} #{dir} /sp /verysilent /suppressmsgboxes"
end
end
It's a bit simplified, but this is the gist of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With