问题
I am going through the "Learn to install and manage your own Chef server / Manage a node on your Chef server" tutorial over at learn.chef.io but have run into an issue that Google apparently doesn't know about.
I'm trying to run everything locally, so have the following set up:
- Chef Workstation - my Fedora 20 laptop
- Chef Server - a VM running CentOS 7 minimal
- Chef Node - another VM running CentOS 7 minimal
I've set up the Workstation and Server, users and organisations, extracted the Starter Kit, and all appears to be working just fine.
When I try to bootstrap my Chef Node, it fails like so:
$ knife bootstrap centos-slave1.example.com --ssh-user <me> --sudo --identity-file ~/.ssh/id_dsa --node-name centos-slave1 --run-list 'recipe[hello_chef_server]'
Doing old-style registration with the validation key at /home/<me>/chef-repo/.chef/merin-validator.pem...
Delete your validation key in order to use your user credentials instead
Connecting to centos-slave1.example.com
ERROR: RegexpError: end pattern with unmatched parenthesis: /^(for$/i
If I remove that validation key, it still fails with the same error:
Creating new client for centos-slave1
Creating new node for centos-slave1
Connecting to centos-slave1.merin
ERROR: RegexpError: end pattern with unmatched parenthesis: /^(for$/i
I've made no special modifications to anything outside of the tutorial steps. All ports are listening, firewalls open between all components, ssh keys working - basically connectivity in every way seems fine.
I've also tried that bootstrap command using my password, and have even tried removing flags one at a time (right down to just 'knife bootstrap ') - always resulting in the same error.
Any ideas, or even just a push in the right direction would be great. Happy to work things out for myself but I've been stuck on this for a while now (even started over multiple times).
Thanks in advance, Matt
EDIT: Adding knife.rb (with some sensitive info replaced)
$ cat .chef/knife.rb
# See https://docs.getchef.com/config_rb_knife.html for more information on knife configuration options
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "<me>"
client_key "#{current_dir}/<me>.pem"
validation_client_name "merin-validator"
validation_key "#{current_dir}/merin-validator.pem"
chef_server_url "https://chef-master.example.com/organizations/merin"
cookbook_path ["#{current_dir}/../cookbooks"]
回答1:
Thank you to StephenKing for the answer
My .ssh/config contained a line similar to the following:
Host example # Blah blah (for blah)
Once I moved that comment onto its own line 'knife bootstrap' started working. This was confirmed and repeatable using 'knife ssh' afterwards and playing with .ssh/config again
回答2:
I had the same issue today and was stuck for some time till 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 successfully without any issues :) Another alternative could have been fixing all the comments and getting rid of () form the comments.
来源:https://stackoverflow.com/questions/31849062/regexperror-in-chef-when-running-knife-bootstrap