Class: Kitchen::Driver::SSHBase

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/binding/core_ext/ssh_base.rb

Overview

Override converge method from Kitchen::Driver::SSHBase to allow use of Kitchen::Binding

Instance Method Summary collapse

Instance Method Details

#converge(state) ⇒ Object

Overriding to add watching Chef Converge and connecting to binding if started



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kitchen/binding/core_ext/ssh_base.rb', line 26

def converge(state)
  provisioner = instance.provisioner
  provisioner.create_sandbox
  sandbox_dirs = Dir.glob("#{provisioner.sandbox_path}/*")

  binding = instance.binding
  binding.state = state

  Kitchen::SSH.new(*build_ssh_args(state)) do |conn|
    run_remote(provisioner.install_command, conn)
    run_remote(binding.install_command, conn)

    run_remote(provisioner.init_command, conn)
    transfer_path(sandbox_dirs, provisioner[:root_path], conn)
    run_remote(provisioner.prepare_command, conn)

    # Run converge in a thread
    chef_run_thread = Thread.new do
      run_remote(provisioner.run_command, conn)
    end

    # Endlessly check until converge has completed
    while chef_run_thread.alive?
      debug("Chef thread still running")
      debug("Binding server running?: #{binding.test_connection}")
      binding.connect_command if binding.test_connection
    end
  end
ensure
  provisioner && provisioner.cleanup_sandbox
end