AleZucchelli
AleZucchelli

Reputation: 55

Test Kitchen: Chef don't restart after reboot

I have a problem during testing my chef cookbooks using Kitchen. I use Vagrant as a driver and Virtual Box as virtualization system. They running on Linux platform.

I have create a test recipe to reboot my machine. This is the code:

#
# Author:: Alessandro Zucchelli
# Recipe:: test_recipe_required_reboot
#

reboot 'test if kitchen runs when a recipe leaves it to the post-install phase' do
  action :request_reboot
  reason 'Need to reboot when the run completes successfully.'
  delay_mins 1
end

And I configure my .kitchen.yml in this mode:

driver:
  name: vagrant
  gui: true
  boot_timeout: 1200
#  log_level: debug
provisioner:
  name: chef_zero
  require_chef_omnibus: 12.11 # need the RFC 062 exit codes
  retry_on_exit_code: 
    - 35 # 35 is the exit code signaling that the node is rebooting
  max_retries: 3
  multiple_converge: 3
  client_rb:
    exit_status: :enabled # Opt-in to the standardized exit codes
    client_fork: false # Forked instances don't return the real exit code
  #log_level: debug
platforms:
  - name: mybox/win-7-professional-amd64-nocm
    transport:
        name: winrm
        elevated: true
        connection_timeout: 3600
        max_wait_until_ready: 600
        connection_retry_sleep: 300

I expect that by launching the recipe go looped restarting vm more than once. Instead, after the first reboot I get:

      Starting Chef Client, version 12.11.18
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #converge action: [execution expired] on ktest-mybox-win-7-professional-amd64-nocm
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Upvotes: 0

Views: 538

Answers (1)

AleZucchelli
AleZucchelli

Reputation: 55

I solved my problem! I added this parameters (view code block) in kitchen.yml and now works correctly!

  max_retries: 3
  multiple_converge: 3
  wait_for_retry: 600

My recipe now reboot 4 times my VMs!

Upvotes: 1

Related Questions