当 运行 刀 bootstrap 时厨师出现 RegexpError
RegexpError in chef when running knife bootstrap
我正在学习“学习安装和管理您自己的 Chef 服务器 /
在 learn.chef.io 上管理您的 Chef 服务器上的节点”教程,但 运行 遇到了 Google 显然不知道的问题。
我正在尝试 运行 在本地进行所有操作,因此请进行以下设置:
- Chef 工作站 - 我的 Fedora 20 笔记本电脑
- Chef 服务器 - 虚拟机 运行ning CentOS 7 minimal
- Chef 节点 - 另一个 VM 运行ning CentOS 7 minimal
我已经设置了工作站和服务器、用户和组织,提取了初学者工具包,一切似乎都运行良好。
当我尝试 bootstrap 我的 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 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"]
感谢 StephenKing 的回答
我的 .ssh/config 包含类似于以下内容的行:
Host example # Blah blah (for blah)
一旦我将该评论移到它自己的行上,'knife bootstrap' 就开始工作了。之后使用 'knife ssh' 并再次使用 .ssh/config
确认并可重复这一点
我今天遇到了同样的问题并且卡住了一段时间,直到我通过添加 -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 文件,因为它没有在我的系统中的任何地方使用,并且再次成功地尝试了 knife bootstrap 命令,没有任何问题:)另一种选择可能是修复所有评论并删除()形成评论。
我正在学习“学习安装和管理您自己的 Chef 服务器 / 在 learn.chef.io 上管理您的 Chef 服务器上的节点”教程,但 运行 遇到了 Google 显然不知道的问题。
我正在尝试 运行 在本地进行所有操作,因此请进行以下设置:
- Chef 工作站 - 我的 Fedora 20 笔记本电脑
- Chef 服务器 - 虚拟机 运行ning CentOS 7 minimal
- Chef 节点 - 另一个 VM 运行ning CentOS 7 minimal
我已经设置了工作站和服务器、用户和组织,提取了初学者工具包,一切似乎都运行良好。
当我尝试 bootstrap 我的 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 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"]
感谢 StephenKing 的回答
我的 .ssh/config 包含类似于以下内容的行:
Host example # Blah blah (for blah)
一旦我将该评论移到它自己的行上,'knife bootstrap' 就开始工作了。之后使用 'knife ssh' 并再次使用 .ssh/config
确认并可重复这一点我今天遇到了同样的问题并且卡住了一段时间,直到我通过添加 -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 文件,因为它没有在我的系统中的任何地方使用,并且再次成功地尝试了 knife bootstrap 命令,没有任何问题:)另一种选择可能是修复所有评论并删除()形成评论。