Class: ChefApply::Action::InstallChef::Windows

Inherits:
Base
  • Object
show all
Defined in:
lib/chef_apply/action/install_chef/windows.rb

Constant Summary

Constants inherited from Base

Base::PATH_MAPPING

Instance Attribute Summary

Attributes inherited from Base

#config, #target_host

Instance Method Summary collapse

Methods inherited from Base

#download_to_workstation, #lookup_artifact, #name, #perform_action, #perform_local_install, #train_to_mixlib, #upgrading?, #upload_to_target, #version_to_install

Methods inherited from Base

#escape_windows_path, #initialize, #name, #notify, #perform_action, #run, #run_chef

Constructor Details

This class inherits a constructor from ChefApply::Action::Base

Instance Method Details

#install_chef_to_target(remote_path) ⇒ Object

TODO: These methods are implemented, but are currently not runnable - see explanation in InstallChef::Base



35
36
37
38
39
40
41
# File 'lib/chef_apply/action/install_chef/windows.rb', line 35

def install_chef_to_target(remote_path)
  # While powershell does not mind the mixed path separators \ and /,
  # 'cmd.exe' definitely does - so we'll make the path cmd-friendly
  # before running the command
  cmd = "cmd /c msiexec /package #{remote_path.tr("/", "\\")} /quiet"
  target_host.run_command!(cmd)
end

#perform_remote_installObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/chef_apply/action/install_chef/windows.rb', line 21

def perform_remote_install
  require "mixlib/install"
  installer = Mixlib::Install.new({
    platform: "windows",
    product_name: "chef",
    channel: :stable,
    shell_type: :ps1,
    version: "13",
  })
  target_host.run_command! installer.install_command
end

#setup_remote_temp_pathObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/chef_apply/action/install_chef/windows.rb', line 43

def setup_remote_temp_path
  return @temppath if @temppath

  r = target_host.run_command!("Write-Host -NoNewline $env:TEMP")
  temppath = "#{r.stdout}\\chef-installer"

  # Failure here is acceptable - the dir could already exist
  target_host.run_command("New-Item -ItemType Directory -Force -Path #{temppath}")
  @temppath = temppath
end