sjaiswal
sjaiswal

Reputation: 498

ERROR: RegexpError: while using knife bootstrap

ERROR: RegexpError: end pattern with unmatched parenthesis: /^(no$/i

while running knife bootstrap command to bootsrtap a node. I am using my local MAC machine as a workstation to setup the node, I found one similar post here RegexpError in chef when running knife bootstrap but I don't see any problem in my ./ssh/config file. I even tried removing all the comments from the file, and also tried creating an empty config file but nothing seems to be working, would really appreciate any help with this.

Thanks

Upvotes: 0

Views: 60

Answers (1)

sjaiswal
sjaiswal

Reputation: 498

I ran the bootstrap command in debug mode by adding -V -V option and analysed the logs.

knife bootstrap <ip-address> -V -V -x <username> -P <password> --sudo -N <node-name>

I got the below debug logs

    DEBUG: Looking for bootstrap template in /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/bootstrap/templates
DEBUG: Found bootstrap template in /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/bootstrap/templates
DEBUG: Adding <node-ip-address>
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:240:in `initialize': end pattern with unmatched parenthesis: /^(no$/i (RegexpError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:240:in `new'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:240:in `pattern2regex'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:115:in `block (2 levels) in load'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:115:in `select'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:115:in `block in load'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:81:in `foreach'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:81:in `load'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:64:in `block in for'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:63:in `each'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:63:in `inject'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb:63:in `for'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh.rb:262:in `configuration_for'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:231:in `session_options'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:258:in `block in session_from_list'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:255:in `each'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:255:in `session_from_list'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:174:in `configure_session'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/ssh.rb:541:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife/bootstrap.rb:392:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife.rb:416:in `block in run_with_pretty_exceptions'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/local_mode.rb:44:in `with_server_connectivity'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife.rb:415:in `run_with_pretty_exceptions'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/knife.rb:214:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/lib/chef/application/knife.rb:148:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.7.2/bin/knife:25:in `<top (required)>'
    from /usr/local/bin/knife:50:in `load'
    from /usr/local/bin/knife:50:in `<main>'

When I looked into the /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb file in my node instance, the first thing I saw were the comments:

The Net::SSH::Config class is used to parse OpenSSH configuration files,
  # and translates that syntax into the configuration syntax that Net::SSH
  # understands. This lets Net::SSH scripts read their configuration (to
  # some extent) from OpenSSH configuration files (~/.ssh/config, /etc/ssh_config,
  # and so forth).

my ~/.ssh/config file was correct but there were issues with my /etc/ssh_config file, it had multiple comments with () in the same line, for eg: Host * # (no default).I got rid of the ssh_config file completely since it was not being used anywhere in my system and tried the knife bootstrap command again without any issues. Another alternative could have been fixing all the comments and getting rid of () form the comments.

Upvotes: 1

Related Questions