Skip to content

Instantly share code, notes, and snippets.

@Brantone
Last active May 7, 2018 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brantone/20b7c87e2c1810af9d0af6b140002475 to your computer and use it in GitHub Desktop.
Save Brantone/20b7c87e2c1810af9d0af6b140002475 to your computer and use it in GitHub Desktop.
Chef VisualStudio install loop
node['agent']['visualstudio']['versions'].each do |vs|
directory "#{Chef::Config[:file_cache_path]}\\visualstudio\\#{vs.version}\\" do
action :create
recursive true
end
remote_file "#{Chef::Config[:file_cache_path]}\\visualstudio\\#{vs.version}\\#{vs.installer}" do
action :create
source "#{node['agent']['software_repo_root']}/microsoft/vs#{vs.version}/#{vs.installer}"
checksum vs.checksum
end
cookbook_file "#{Chef::Config[:file_cache_path]}\\visualstudio\\#{vs.version}\\AdminDeployment.xml" do
action :create
source "#{vs.version}_AdminDeployment.xml"
notifies :run, "dsc_resource[VisualStudio #{vs.version}]", :immediately
end
dsc_resource "VisualStudio #{vs.version}" do
action :nothing
resource :package
property :name, vs.name
property :ensure, 'Present'
property :path, "#{Chef::Config[:file_cache_path]}\\visualstudio\\#{vs.version}\\#{vs.installer}"
property :arguments, "/norestart /adminfile #{Chef::Config[:file_cache_path]}\\visualstudio\\#{vs.version}\\AdminDeployment.xml"
property :productid, vs.productid
notifies :request_reboot, 'reboot[Rebooting to complete Microsoft agent installs]', :delayed
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment