Skip to content

Instantly share code, notes, and snippets.

@swade1987
Created March 18, 2016 10:57
Show Gist options
  • Select an option

  • Save swade1987/570790da698679436943 to your computer and use it in GitHub Desktop.

Select an option

Save swade1987/570790da698679436943 to your computer and use it in GitHub Desktop.
#
# Cookbook Name:: Continuous Delivery Pipline Demo Web
# Recipe:: default
#
# Copyright (C) 2016 Steven Wade
#
# All rights reserved - Do Not Redistribute
#
Chef::Log.info "Installing chocolatey ..."
include_recipe 'chocolatey'
# obtain the version and name of the artefact we want to deploy by looking in our metadata.rb file.
installing_version = run_context.cookbook_collection[cookbook_name].metadata.version
component_name = run_context.cookbook_collection[cookbook_name].metadata.name
Chef::Log.info "Uninstalling #{component_name} to version #{installing_version}"
chocolatey "#{component_name}" do
source node['chocolatey']['Uri']
version installing_version
options ({'u' => node['chocolatey']['username'], 'p' => node['chocolatey']['password']})
action :remove
end
Chef::Log.info "Installing #{component_name} to version #{installing_version}"
# get chocolatey to install the version of the artefact in the metadata.rb using the Chocolatey source defined in "attributes\default.rb"
chocolatey "#{component_name}" do
source node['chocolatey']['Uri']
version installing_version
options ({'u' => node['chocolatey']['username'], 'p' => node['chocolatey']['password']})
action :install
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment