Module: ChefApply::TargetHost::Windows
- Defined in:
- lib/chef_apply/target_host/windows.rb
Constant Summary collapse
- MKTEMP_COMMAND =
- "$parent = [System.IO.Path]::GetTempPath();" + "[string] $name = [System.Guid]::NewGuid();" + "$tmp = New-Item -ItemType Directory -Path " + "(Join-Path $parent $name);" + "$tmp.FullName".freeze 
Instance Method Summary collapse
- #chown(path, owner) ⇒ Object
- #del_dir(path) ⇒ Object
- #del_file(path) ⇒ Object
- #install_package(target_package_path) ⇒ Object
- #make_temp_dir ⇒ Object
- #mkdir(path) ⇒ Object
- #omnibus_manifest_path ⇒ Object
- #ws_cache_path ⇒ Object
Instance Method Details
#chown(path, owner) ⇒ Object
| 20 21 22 23 24 25 | # File 'lib/chef_apply/target_host/windows.rb', line 20 def chown(path, owner) # This implementation left intentionally blank. # To date, we have not needed chown functionality on windows; # when/if that changes we'll need to implement it here. nil end | 
#del_dir(path) ⇒ Object
| 47 48 49 | # File 'lib/chef_apply/target_host/windows.rb', line 47 def del_dir(path) run_command!("Remove-Item -Recurse -Force –Path #{path}") end | 
#del_file(path) ⇒ Object
| 43 44 45 | # File 'lib/chef_apply/target_host/windows.rb', line 43 def del_file(path) run_command!("If (Test-Path #{path}) { Remove-Item -Force -Path #{path} }") end | 
#install_package(target_package_path) ⇒ Object
| 34 35 36 37 38 39 40 41 | # File 'lib/chef_apply/target_host/windows.rb', line 34 def install_package(target_package_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 #{target_package_path.tr("/", "\\")} /quiet" run_command!(cmd) nil end | 
#make_temp_dir ⇒ Object
| 27 28 29 30 31 32 | # File 'lib/chef_apply/target_host/windows.rb', line 27 def make_temp_dir @tmpdir ||= begin res = run_command!(MKTEMP_COMMAND) res.stdout.chomp.strip end end | 
#mkdir(path) ⇒ Object
| 16 17 18 | # File 'lib/chef_apply/target_host/windows.rb', line 16 def mkdir(path) run_command!("New-Item -ItemType Directory -Force -Path #{path}") end | 
#omnibus_manifest_path ⇒ Object
| 5 6 7 8 9 10 11 12 13 14 | # File 'lib/chef_apply/target_host/windows.rb', line 5 def omnibus_manifest_path # TODO - use a proper method to query the win installation path - # currently we're assuming the default, but this can be customized # at install time. # A working approach is below - but it runs very slowly (~10s) in testing # on a virtualbox windows vm: # (over winrm) Get-WmiObject Win32_Product | Where {$_.Name -match 'Chef Client'} # TODO - if habitat install on target, this won't work "c:\\opscode\\chef\\version-manifest.json" end | 
#ws_cache_path ⇒ Object
| 51 52 53 | # File 'lib/chef_apply/target_host/windows.rb', line 51 def ws_cache_path '#{ENV[\'APPDATA\']}/chef-workstation' end |