“ TypeError:在刀头引导过程中没有将nil隐式转换为String”

时间:2018-07-20 13:01:21

标签: ruby-on-rails ruby chef chef-recipe knife

当我使用“ knife bootstrap”命令将节点连接到厨师服务器时,我遇到了这个问题。

  

使用...的验证码进行旧式注册       删除验证密钥,以改为使用您的用户凭据

     

连接到xx.xx.xxx.xxx(某些IP地址)       错误:TypeError:没有将nil隐式转换为String

当我在google中搜索时,我得到了有关“使用...的验证码进行旧式注册”的一些答案,但是我在该行上方的“ ...”中看到了一些位置。

我不知道我在做什么错。

厨师信息: 我将GCP用于工作站,节点和服务器"manage.chef.io"(厨师服务器)

  

注意:请参阅下面的评论

当我执行此命令时:

knife bootstrap 35.XX.xx.x --ssh-user USER-NAME --sudo --identity-file SSH-FILE-LOCATION -N node1 -VV

我得到这个:

INFO: Using configuration from /home/sandeep.nayak/chef-repo/.chef/knife.rb
Doing old-style registration with the validation key at ...
Delete your validation key in order to use your user credentials instead

Connecting to 35.200.203.207
Traceback (most recent call last):
        16: from /usr/bin/knife:75:in `<main>'
        15: from /usr/bin/knife:75:in `load'
        14: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/bin/knife:24:in `<top (required)>'
        13: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/application/knife.rb:161:in `run'
        12: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife.rb:220:in `run'
        11: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife.rb:441:in `run_with_pretty_exceptions'
        10: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/local_mode.rb:44:in `with_server_connectivity'
         9: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife.rb:442:in `block in run_with_pretty_exceptions'
         8: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/bootstrap.rb:391:in `run'
         7: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/bootstrap.rb:426:in `knife_ssh'
         6: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/bootstrap.rb:448:in `ssh_command'
         5: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/bootstrap.rb:354:in `render_template'
         4: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate'
         3: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval'
         2: from (erubis):196:in `block in evaluate'
         1: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/core/bootstrap_context.rb:49:in `validation_key'
/opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/lib/chef/knife/core/bootstrap_context.rb:49:in `expand_path': no implicit conversion of nil into String (TypeError)

我的knife.rb文件:

# See http://docs.chef.io/config_rb_knife.html for more information on knife configuration options

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "techrealm"
client_key               "#{current_dir}/techrealm.pem"
chef_server_url          "https://api.chef.io/organizations/techrealm"
cookbook_path            ["#{current_dir}/../cookbooks"]

尝试解决此问题时,我很少注意到:

  1. 最初,我无法在工作站的/ etc / chef中看到名为“ validation.pem”的文件(我不知道在哪里存在validate.pem文件(工作站或节点))。所以我尝试了

    刀配置客户端/ etc / chef 它创建了两个文件 1。 client.pem 2。 validate.pem ,但validation.pem文件为空。

  2. 我在

  3. 上看到一些红宝石线
  

默认(:validation_key)       {Chef_zero.enabled吗? nil:platform_specific_path(“ / etc / chef / techrealm.pem”)}

在此位置“ opt / chef / embedded / lib / ruby​​ / gems / 2.5.0 / gems / chef-config-14.3.37 / lib / chef-config / config.rb”

希望这对您有帮助

0 个答案:

没有答案