Sha256: 91520489e30c03429166cfeedb95a069df6d7f1bc8caf602aa4a5d749fb37c4f

Contents?: true

Size: 1.08 KB

Versions: 26

Compression:

Stored size: 1.08 KB

Contents

require 'pe_build/on_machine'

# Download PE installers to a Windows VM
#
# @since 0.14.0
class PEBuild::Cap::StageInstaller::Windows

  extend PEBuild::OnMachine

  # Download an installer to a remote VM
  #
  # @param uri [URI] A URI containing the download source.
  # @param dest_dir [String] The destination directory to download the
  #   installer to.
  #
  # @return [void]
  def self.stage_installer(machine, uri, dest_dir='.')
    filename = File.basename(uri.path)

    unless machine.communicate.test(%Q[If (Test-Path "#{dest_dir}/#{filename}) { Exit 0 } Else { Exit 1 }])
      machine.ui.info I18n.t('pebuild.cap.stage_installer.downloading_installer',
        :url => uri)

      # Setting ServerCertificateValidationCallback to always return true
      # allows us to download from HTTPS sources that present a self-signed
      # certificate. For example, a Puppet Master.
      on_machine(machine, <<-EOS)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
(New-Object System.Net.WebClient).DownloadFile("#{uri}","#{dest_dir}/#{filename}")
EOS
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
vagrant-pe_build-0.18.0 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.14 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.13 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.12 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.11 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.10 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.9 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.8 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.7 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.6 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.5 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.4 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.3 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.2 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.1 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.17.0 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.16.0 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.15.6 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.15.5 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.15.4 lib/pe_build/cap/stage_installer/windows.rb