Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating install.bat to allow installation from local path on windows #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vinyar
Copy link

@vinyar vinyar commented Jan 28, 2015

please take a look @smurawski

note: i couldn't make the powershell block pretty, seems as if tac (`) doesn't work as a carriage return escape with -command or perhaps ruby is eating.. dunno

@@ -214,7 +214,7 @@ def fetch_or_create_install_script(env)
set version=%1
set dest=%~dp0chef-client-%version%-1.windows.msi
echo Downloading Chef %version% for Windows...
powershell -command "(New-Object System.Net.WebClient).DownloadFile('#{url}?v=%version%', '%dest%')"
powershell -command "if(test-path '#{url}/chef-client*%version%*.msi'){[array]$tempstore = dir #{url} | ?{$_.name -like 'chef-client*%version%*.msi'};copy $tempstore[0].fullname %dest%}else{(New-Object System.Net.WebClient).DownloadFile('#{url}?v=%version%', '%dest%')}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do something like

[uri]$uri='#{url}';switch -regex ($uri.scheme){('http(s*)'{$source='#{url}v=%version%'}'default{[$source=(resolve-path (join-path '#{url}' 'chef-client*%version%*.msi')).path)} };(new-object Net.Webclient).DownloadFile(([uri]$source).absoluteuri, '%dest%')}

for the PowerShell command. Casting it to a URI allows you to determine if it is http(s) or a file path (or no scheme if it is a partial path), then you can determine how to append the version details. Using join-path and resolve-path can assemble the file or unc path appropriately and the casting the result of that to a uri allows either the http or file scheme to be used with webclient (no need to switch back and forth between copy or webclient download.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URI exactly what I was looking for. I figured there is a single construct that allows for both. Big thanks, I'll play with it and amend the pull request. Also, I didnt know web-client can download local files via URI :) live and learn.

@alexpop
Copy link

alexpop commented Jan 31, 2015

Gents, let me know when you have something to test.

I'm trying to have this setup work in kitchen to avoid downloading the msi from the internet.

  name: chef_zero
  require_chef_omnibus: 12.0.3
  chef_omnibus_url: file:///c:/share/chef/chef-client-12.0.3-1.msi

@alexpop
Copy link

alexpop commented Jan 31, 2015

Vagrant is not showing this 'vagrant-omnibus' plugin for me. Is it shipped with kitchen?

[10:10:44 /]$ vagrant -v Vagrant 1.7.1 [10:10:17 /]$ vagrant plugin list vagrant-share (1.1.4, system) [10:10:44 /]$

@vinyar
Copy link
Author

vinyar commented Feb 2, 2015

@alexpop I dont think vagrant-omnibus is shipps with chefdk or kitchen. I just add it via
vagrant plugin install vagrant-omnibus

The code in my original pull request works - though it's intended for windows only. It's actually what I'm using at the moment to get my 2k8 vagrant instances updated.

config.vm.synced_folder '~/Documents/ISO_BOX_etc/binaries', "c:/parent_binaries"
config.omnibus.install_url = 'c:\\parent_binaries\\chef_client'

I suspect for Linux instances below will work w/o any changes (it's what's in the read me right now)

config.omnibus.install_url = '/some/local/path'

@tmatilai
Copy link
Contributor

No, vagrant-omnibus is not shipped nor used by Test Kitchen, see my comment here for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants