Repository: test-kitchen/test-kitchen

Issue #565: windows-guest-support: wrong path for chef-client
Created: 2014-12-18T02:22:30Z
the windows-guest-support branch doesn't appear to support looking for omnibus on a windows guest.
or maybe its that I'm using a windows host? not sure yet.
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #converge action: [Transport WinRM exited (1) using shell [powershell] for command: [/opt/chef/bin/chef-client --local-mode --config /tmp/kitchen/client.rb --log_level auto --force-formatter --no-color --chef-zero-port 8889 --json-attributes /tmp/kitchen/dna.json]
REMOTE ERROR:
/opt/chef/bin/chef-client : The term '/opt/chef/bin/chef-client' is not
recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:42
+  $ProgressPreference='SilentlyContinue'; /opt/chef/bin/chef-client
--local-mode  ...
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/opt/chef/bin/chef-client:Strin
   g) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Duplicate issue #596: Kitchen converge on Windows guests takes two tries
Created: 2015-02-04T20:48:22Z
For some reason, running kitchen converge (from the windows-guest-support branch) fails the first time, but the second time it runs fine. Here is the output:
I, [2015-02-04T14:33:09.808630 #5270]  INFO -- Kitchen: -----> Starting Kitchen (v1.3.2.dev)
I, [2015-02-04T14:33:11.054569 #5270]  INFO -- Kitchen: -----> Destroying <default-windows-2008r2>...
I, [2015-02-04T14:33:15.828362 #5270]  INFO -- Kitchen: -----> Kitchen is finished. (0m6.02s)
I, [2015-02-04T14:33:23.120034 #5324]  INFO -- Kitchen: -----> Starting Kitchen (v1.3.2.dev)
I, [2015-02-04T14:33:24.209603 #5324]  INFO -- Kitchen: -----> Creating <default-windows-2008r2>...
I, [2015-02-04T14:34:52.993433 #5324]  INFO -- Kitchen: -----> Converging <default-windows-2008r2>...
E, [2015-02-04T14:40:28.720037 #5324] ERROR -- Kitchen: ------Exception-------
E, [2015-02-04T14:40:28.720083 #5324] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2015-02-04T14:40:28.720101 #5324] ERROR -- Kitchen: Message: Failed to complete #converge action: [Transport WinRM exited (1) using shell [powershell] for command: [
# @return True if chef path exist, False otherwise
function is_chef_installed { Test-Path /opscode/chef }

# @param $version the requested version of omnibus package
# @return True if omnibus needs to be installed, False otherwise
function should_update_chef($version) {
  if (-Not (is_chef_installed)) { return $true }

  try {
    $chef_version=(chef-solo -v).split(' ',2)[1]
  } catch [Exception] {
    $chef_version = ''
  }

  switch ($version) {
    { 'true', $chef_version -contains $_ } { return $false }
    'latest' { return $true }
    default { return $true }
  }
}

# @param $chef_url The url where we will download chef
# @param $chef_msi Temporal MSI path
function download_chef($chef_url, $chef_msi) {
  Write-Host -NoNewline "`r`tDownloading Chef..."
  (New-Object System.Net.WebClient).DownloadFile($chef_url, $chef_msi)
  Write-Host -NoNewline "`r`tDone!              "
}

# function to install chef with sort of a nice progress bar
function install_chef {
  $proc_msi = Start-Process -FilePath 'msiexec.exe' -ArgumentList "/qn /i $chef_msi" -Passthru
  $bar = ""
  while (-Not $proc_msi.HasExited ) {
    Write-Host -NoNewline "`r`t[MSI] [$bar"
    Start-Sleep 2
    $bar += "#"
  }

  if ($proc_msi.ExitCode -ne 0) {
    throw "msiexec was not successful. Received exit code $($proc_msi.ExitCode)"
  }
  rm -r $chef_msi
  Write-Host -NoNewline "`r`t[MSI] [$bar] Completed!
"
}

  $chef_msi = $env:systemdrive + "\chef.msi"

  If (should_update_chef 11.16.4) {
    Write-Host "-----> Installing Chef Omnibus (11.16.4)
"
    download_chef "http://www.chef.io/chef/install.msi?v=11.16.4" $chef_msi
    install_chef
  } else {
    Write-Host "-----> Chef Omnibus installation detected (11.16.4)
"
  }
]
REMOTE ERROR:
msiexec was not successful. Received exit code 
At line:42 char:10
+     throw &lt;&lt;&lt;&lt;  "msiexec was not successful. Received exit code $($proc_msi.E
xitCode)"
    + CategoryInfo          : OperationStopped: (msiexec was not...ived exit c 
   ode :String) [], RuntimeException
    + FullyQualifiedErrorId : msiexec was not successful. Received exit code ]
E, [2015-02-04T14:40:28.720118 #5324] ERROR -- Kitchen: ---Nested Exception---
E, [2015-02-04T14:40:28.720130 #5324] ERROR -- Kitchen: Class: Kitchen::Transport::TransportFailed
E, [2015-02-04T14:40:28.720142 #5324] ERROR -- Kitchen: Message: Transport WinRM exited (1) using shell [powershell] for command: [
# @return True if chef path exist, False otherwise
function is_chef_installed { Test-Path /opscode/chef }

# @param $version the requested version of omnibus package
# @return True if omnibus needs to be installed, False otherwise
function should_update_chef($version) {
  if (-Not (is_chef_installed)) { return $true }

  try {
    $chef_version=(chef-solo -v).split(' ',2)[1]
  } catch [Exception] {
    $chef_version = ''
  }

  switch ($version) {
    { 'true', $chef_version -contains $_ } { return $false }
    'latest' { return $true }
    default { return $true }
  }
}

# @param $chef_url The url where we will download chef
# @param $chef_msi Temporal MSI path
function download_chef($chef_url, $chef_msi) {
  Write-Host -NoNewline "`r`tDownloading Chef..."
  (New-Object System.Net.WebClient).DownloadFile($chef_url, $chef_msi)
  Write-Host -NoNewline "`r`tDone!              "
}

# function to install chef with sort of a nice progress bar
function install_chef {
  $proc_msi = Start-Process -FilePath 'msiexec.exe' -ArgumentList "/qn /i $chef_msi" -Passthru
  $bar = ""
  while (-Not $proc_msi.HasExited ) {
    Write-Host -NoNewline "`r`t[MSI] [$bar"
    Start-Sleep 2
    $bar += "#"
  }

  if ($proc_msi.ExitCode -ne 0) {
    throw "msiexec was not successful. Received exit code $($proc_msi.ExitCode)"
  }
  rm -r $chef_msi
  Write-Host -NoNewline "`r`t[MSI] [$bar] Completed!
"
}

  $chef_msi = $env:systemdrive + "\chef.msi"

  If (should_update_chef 11.16.4) {
    Write-Host "-----> Installing Chef Omnibus (11.16.4)
"
    download_chef "http://www.chef.io/chef/install.msi?v=11.16.4" $chef_msi
    install_chef
  } else {
    Write-Host "-----> Chef Omnibus installation detected (11.16.4)
"
  }
]
REMOTE ERROR:
msiexec was not successful. Received exit code 
At line:42 char:10
+     throw &lt;&lt;&lt;&lt;  "msiexec was not successful. Received exit code $($proc_msi.E
xitCode)"
    + CategoryInfo          : OperationStopped: (msiexec was not...ived exit c 
   ode :String) [], RuntimeException
    + FullyQualifiedErrorId : msiexec was not successful. Received exit code 
E, [2015-02-04T14:40:28.720184 #5324] ERROR -- Kitchen: ------Backtrace-------
E, [2015-02-04T14:40:28.720223 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/transport/winrm.rb:56:in `execute'
E, [2015-02-04T14:40:28.720248 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/driver/base.rb:68:in `block in converge'
E, [2015-02-04T14:40:28.720269 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/transport/base.rb:73:in `connection'
E, [2015-02-04T14:40:28.720308 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/driver/base.rb:67:in `converge'
E, [2015-02-04T14:40:28.720330 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/kitchen-vagrant-246bfde2369b/lib/kitchen/driver/vagrant.rb:79:in `converge'
E, [2015-02-04T14:40:28.720343 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:378:in `public_send'
E, [2015-02-04T14:40:28.720354 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:378:in `block in perform_action'
E, [2015-02-04T14:40:28.720366 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:442:in `call'
E, [2015-02-04T14:40:28.720377 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:442:in `synchronize_or_call'
E, [2015-02-04T14:40:28.720387 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:407:in `block in action'
E, [2015-02-04T14:40:28.720398 #5324] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
E, [2015-02-04T14:40:28.720409 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:406:in `action'
E, [2015-02-04T14:40:28.720419 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:378:in `perform_action'
E, [2015-02-04T14:40:28.720455 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:338:in `converge_action'
E, [2015-02-04T14:40:28.720472 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:318:in `block in transition_to'
E, [2015-02-04T14:40:28.720483 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:317:in `each'
E, [2015-02-04T14:40:28.720511 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:317:in `transition_to'
E, [2015-02-04T14:40:28.720524 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/instance.rb:138:in `converge'
E, [2015-02-04T14:40:28.720534 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/command.rb:176:in `public_send'
E, [2015-02-04T14:40:28.720544 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/bundler/gems/test-kitchen-5b6a7ec033bd/lib/kitchen/command.rb:176:in `block (2 levels) in run_action'
E, [2015-02-04T14:40:28.720554 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
E, [2015-02-04T14:40:28.720564 #5324] ERROR -- Kitchen: /Users/mattstratton/.chefdk/gem/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
E, [2015-02-04T14:40:28.720575 #5324] ERROR -- Kitchen: ----------------------

Here's my .kitchen.yml:

---
driver:
  forward_agent: yes
  name: vagrant
  vm_hostname: false # do not bother trying to change the hostname (sometimes fails)
  customize:
    cpus: 2
    memory: 4096

transport:
  name: winrm

provisioner:
  name: chef_zero

platforms:
  - name: windows-2008r2
    driver_config:
      box: win2k8r2
      box_url: redacted
    provisioner:
      require_chef_omnibus: 11.16.4

suites:
  - name: default
    run_list:
      - recipe[redacted::default]

Note that this same behavior occurs with chef-client set to 12.0.3.

Closing comment (2015-02-06T03:26:13Z): Duplicate of #565