我正在学习“学习如何安装和管理自己的Chef服务器/ 管理您的Chef服务器上的节点“learn.chef.io上的教程,但遇到了谷歌显然不知道的问题。
我正在尝试在本地运行所有内容,因此请进行以下设置:
我已经设置了工作站和服务器,用户和组织,提取了入门套件,所有这些工具似乎都运行正常。
当我尝试引导我的Chef节点时,它会失败:
$ 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
如果我删除了该验证密钥,它仍然会失败并出现相同的错误:
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
我没有对教程步骤之外的任何内容进行任何特殊修改。所有端口都在监听,防火墙在所有组件之间打开,ssh密钥正常工作 - 基本上各方面的连接似乎都很好。
我也尝试过使用我的密码的bootstrap命令,甚至尝试一次删除一个标记(直到'刀引导') - 总是导致相同的错误。
任何想法,甚至只是推动正确的方向都会很棒。很乐意为自己解决问题,但我已经坚持了一段时间(甚至多次开始)。
提前致谢, 马特
修改 添加knife.rb(替换了一些敏感信息)
$ 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"]
答案 0 :(得分:1)
感谢StephenKing的回答
我的.ssh / config包含类似于以下内容的行:
Host example # Blah blah (for blah)
一旦我将评论移到了自己的行上,'刀引导'就开始工作了。之后使用'knife ssh'并再次使用.ssh / config进行确认和重复
答案 1 :(得分:0)
今天我遇到了同样的问题并且一直停留了一段时间,直到我通过添加-V -V选项并分析日志来在调试模式下运行bootstrap命令。
knife bootstrap <ip-address> -V -V -x <username> -P <password> --sudo -N <node-name>
我得到了以下调试日志
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>'
当我查看节点实例中的/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/net-ssh-3.0.2/lib/net/ssh/config.rb
文件时,我看到的第一件事是评论:
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).
我的~/.ssh/config
文件是正确的但我的/etc/ssh_config
文件存在问题,它在同一行中有多个带()的注释,例如:Host * # (no default)
。我摆脱了ssh_config文件完全没有在我的系统中的任何地方使用,并且成功地再次尝试了刀引导命令而没有任何问题:)另一种选择可能是修复所有注释并从中删除()形成注释。