The test kitchen does not try to restart on the 2012R2 server

My cookbook requires the guest to reboot after installing WMF5 on Windows Server 2012R2.

reboot 'Reboot Windows' do
  action :nothing
end

chocolatey 'DotNet4.5.1' do
  version '4.5.1.20140606'
  action :install
end

chocolatey 'Powershell' do
  version '5.0.10586.20161027'
  action :install
  options ({ '-ignore-package-exit-codes' => '' })
end

powershell_script 'Reboot if PowerShell v4' do
  notifies :reboot_now, 'reboot[Reboot Windows]', :immediately
  only_if { reboot_pending? }
end

When rebooting, the test kitchen will exit the system without trying to shift again. I also can not see the exit code.

D      [WinRM] Waiting for output...
D      [WinRM] Processing output
         - execute the ruby block track-path-Powershell

     * powershell_script[Reboot if PowerShell v4] action run
       - execute "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20161212-936-452h54.ps1"
     * reboot[Reboot Windows] action reboot_now[2016-12-12T15:44:04-05:00] WARN: Rebooting system immediately, requested by 'Reboot Windows'


       Running handlers:
       Running handlers complete
       Chef Client finished, 54/140 resources updated in 02 minutes 46 seconds
   [2016-12-12T15:44:04-05:00] WARN: Rebooting server at a recipe request. Details: {:delay_mins=>0, :reason=>"Reboot by Chef", :timestamp=>2016-12-12 15:44:04 -0500, :requested_by=>"Reboot Windows"}
D      [WinRM] Waiting for output...
D      [WinRM] Processing output
D      [WinRM] cleaning up command_id: 737D4041-AE48-4403-ADEC-840D31B1FE0E on shell_id B4370D6D-AE03-46E3-9823-EFB3EF2EA14C
$$$$$$ DL is deprecated, please use Fiddle
D      Cleaning up local sandbox in     C:/Users/lsmit648/AppData/Local/Temp/default-windows2012r2min-sandbox-20161212-12432-rf5u0f
       Finished converging <default-windows2012r2min> (3m19.06s).
-----> Kitchen is finished. (3m58.02s)

Here is my .kitchen.yaml file

---
driver:
  name: vagrant
  provider: virtualbox
  gui: false
  box_check_update: true
  vm_hostname: false
  communicator: winrm
  guest: windows
  customize:
    natdnshostresolver1: 'on'
    natdnsproxy1: 'on'
    usb: 'off'
  reset_command: "exit 0"
  username: 'vagrant'
  password: 'vagrant'
  winrm:
    boot_timeout: 600
    max_tries: 500

# https://github.com/chef/chef-dk/issues/1009#issuecomment-246875683
transport:
  name: winrm
  username: 'vagrant'
  password: 'vagrant'
  elevated: true

provisioner:
  name: chef_zero
  retry_on_exit_code:
    - [35, 1]
  max_retries: 5
  wait_for_retry: 60
  client_rb:
    exit_status: :enabled

verifier:
  name: inspec

platforms:
  - name: windows2012.r2.min
    transport:
      port: 5985
    os_type: windows
    shell_type: powershell
    driver:
      box: windows2012.r2.min
      box_url: <%= ENV['VAGRANT_BOX_REPOSITORY'] %>/windows2012.r2min.json
      port: 5985
      winrm:
        guest_port: 5985
      network:
        - ['forwarded_port', {guest: 3389, host: 9561, id: 'rdp', auto_correct: true}]
        - ['forwarded_port', {guest: 5985, host: 9571, id: 'winrm', auto_correct: true}]
suites:
  - name: default
    run_list:
      - recipe[chocolatey::default]
      - recipe[wmf_5]
      - recipe[roles_features]

How can I capture the exit code that is used to reboot in order to try to collapse again?

+4
source share
1 answer

I found out the problem.

The default cook client was 12.8.1

I needed to have a minimum version of 12.11 for correctly returning exit codes

+2
source

Source: https://habr.com/ru/post/1663528/


All Articles