Class: PEBuild::Cap::RunInstall::Windows

Inherits:
Object
  • Object
show all
Extended by:
OnMachine
Defined in:
lib/pe_build/cap/run_install/windows.rb

Class Method Summary collapse

Methods included from OnMachine

on_machine

Class Method Details

.run_install(machine, config, archive) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pe_build/cap/run_install/windows.rb', line 6

def self.run_install(machine, config, archive)

  gt_win2k3_path = '${Env:ALLUSERSPROFILE}\\PuppetLabs'
  le_win2k3_path = '${Env:ALLUSERSPROFILE}\\Application Data\\PuppetLabs'
  testpath = "(Test-Path \"#{gt_win2k3_path}\") -or (Test-Path \"#{le_win2k3_path}\")"

  if machine.communicate.test("If (#{testpath}) { Exit 0 } Else { Exit 1 }")
    machine.ui.warn I18n.t('pebuild.cap.run_install.already_installed'),
      :name => machine.name
    return
  end

  root = machine.communicate.shell.cmd('ECHO %SYSTEMDRIVE%')[:data][0][:stdout].chomp
  root = File.join("#{root}\\vagrant", PEBuild::WORK_DIR)

  # The installer will be fed to msiexec. That means the File.join() method
  # is of limited use since it won't execute on the Windows system
  installer = File.join(root, archive.to_s).gsub('/', '\\')

  cmd = []
  cmd << 'msiexec' << '/qn' << '/i' << installer

  cmd << "PUPPET_MASTER_SERVER=#{config.master}"
  cmd << "PUPPET_AGENT_CERTNAME=#{machine.name}"

  argv = cmd.join(' ')

  on_machine(machine, argv)

end