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.15.3 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.15.1 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.15.0 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.14.2 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.14.1 lib/pe_build/cap/stage_installer/windows.rb
vagrant-pe_build-0.14.0 lib/pe_build/cap/stage_installer/windows.rb