Class: PEBuild::Cap::RunInstall::Windows
- Inherits:
-
Object
- Object
- PEBuild::Cap::RunInstall::Windows
- Extended by:
- OnMachine
- Defined in:
- lib/pe_build/cap/run_install/windows.rb
Class Method Summary collapse
-
.run_install(machine, installer_path, answers, **options) ⇒ void
Run the PE installer on Windows systems.
Methods included from OnMachine
Class Method Details
.run_install(machine, installer_path, answers, **options) ⇒ void
This method returns an undefined value.
Run the PE installer on Windows systems
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pe_build/cap/run_install/windows.rb', line 17 def self.run_install(machine, installer_path, answers, **) = answers.map{|e| e.join('=')}.join(' ') # Lots of PowerShell commands can handle UNIX-style paths. msiexec can't. installer_path = installer_path.gsub('/', '\\') cmd = <<-EOS $WorkingDirectory = (Get-Item -Path "#{installer_path}" -ErrorVariable InstallerMissing).Directory.FullName If ($InstallerMissing) { Exit 1 } $Package = (Get-Item -Path "#{installer_path}").FullName $LogFile = "${WorkingDirectory}\\puppet-enterprise-installer.log" $params = @( "/qn", "/i `"${Package}`"", "/l*v `"${LogFile}`"", "#{}" ) Write-Host "Running msiexec to install: ${Package}" $Result = (Start-Process -FilePath "msiexec.exe" -ArgumentList $params -Wait -Passthru).ExitCode If ($Result -ne 0) { $HOST.UI.WriteErrorLine("msiexec failed with exitcode: ${Result}") $HOST.UI.WriteErrorLine("Contents of ${LogFile}:") Get-Content "${LogFile}" | ForEach-Object { $HOST.UI.WriteErrorLine($_) } } Else { Write-Host "msiexec completed with exitcode: ${Result}" } Exit $Result EOS on_machine(machine, cmd) end |