Chef provisioning ssh times out when used with chef zero

316 views Asked by At

I am using Chef zero on my windows machine to ssh into a red hat linux machine and execute a command that's inside of a recipe. When I run the code below, it tries to SSH for 120 secs and times out. I'm not sure why this is happening. Any idea why this is happening?

require 'chef/provisioning'
require 'chef/provisioning/ssh_driver'
  with_driver 'ssh'
  machine "ssh" do

    attribute "short_dns", new_resource.short_dns
    attribute "long_dns", load_balancer_name
    recipe "mycookbook::add_short_dns"
    machine_options :transport_options => {
      'is_windows' => false,
      'ip_address' => '10.16.99.124',
      'username' => 'myusername',
      'ssh_options' => {
      'password' => 'mypassword'
      }
    }
    converge true

  end

here is the error

- been waiting 110/120 -- sleeping 10 seconds for ssh (10.16.99.124 on ssh:C:/Users/user/.chef/provisioning/ssh) to be connectable ...[2015-06-23T14:54:33-05:00] INFO: Executing sudo pwd on [email protected]

================================================================================
Error executing action `converge` on resource 'machine[ssh]'
================================================================================

RuntimeError
------------
Machine ssh (10.16.99.124 on ssh:C:/Users/user/.chef/provisioning/ssh) did not become ready within 120 seconds
3

There are 3 answers

1
Brent On

I'm still fighting with Chef Provisioning myself, so this may not be as helpful as I would like. One thing is that each of these is a key/value pair, so want to declare your variables differently (see below):

require 'chef/provisioning/ssh_driver'
with_driver 'ssh'
  with_machine_options :transport_options => {
    :username => 'centos',
    :ssh_options => {
      :password => 'password'
    }
  }
1
Zack On

Amir,

Does the :C/Users/user/.chef/provisioning/ssh directory exist on your workstation? If not try creating it and making sure permissions are correct then try

0
Baurito On

Try to use the snippet below, notice extra options that will help you to debug an issue.

1) DEBUG level will allow to see SSH communication.

2) If you don't overwrite prefix, it will use SUDO by default

3) Sometimes when you recreate remote server, your "known_hosts" file remembers it and the next time you try to SSH into server after recreation, you receive thie message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED". In fact SSH session hangs, but you don't see that on the client side. So better ignore it.

    :transport_options => {
      :is_windows => false,
      :username => 'YOURUSER',
      :ssh_options => {
        :password => 'YOURPASSWRD',
        :verbose => Logger::DEBUG,
        :user_known_hosts_file => '/dev/null'
      },
      :options => {
        :prefix => ''
      }
    },