Pergunta

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?

Foi útil?

Solução 2

It's by far the "best practices" but I hacked my way through here. It leverages the windows cookbook mainly. Basically I read the main windows resource docs and ran chef-client/solo over and over.

Outras dicas

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.

Some of the existing cookbooks out there support the windows platform, but from my experience they tend to be pretty buggy. I've had more success with the chocolatey coobook.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top