【问题标题】:knife bootstrap is failing --node-ssl-verify-mode none is not working刀引导失败--node-ssl-verify-mode none 不起作用
【发布时间】:2019-05-04 21:34:37
【问题描述】:
knife ec2 server create -E staging --node-name temp-chef-upgrade-test -f t2.small -r "recipe[base]"  -g xxxx -x ubuntu -I ami-49c9295f --subnet xxx -S xxxx -i xxxx --server-connect-attribute private_ip_address --node-ssl-verify-mode none  --no-node-verify-api-cert

我也将以下两个标志都设置到了我的刀.rb

ssl_verify_mode          :verify_none
verify_api_cert          false

主厨客户端版本

Chef 12.19.36

厨师服务员

12.13

错误

xx.xx.xx.xx [2017-03-28T10:02:03+00:00] ERROR: SSL Validation failure connecting to host: xx.xx.xx.xx - hostname "xx.xx.xx.xx" does not match the server certificate
xx.xx.xx.xx [2017-03-28T10:02:03+00:00] ERROR: SSL Error connecting to https://xx.xx.xx.xx/clients, retry 1/5

【问题讨论】:

  • 您遇到了哪个错误?验证模式只会让自签名证书或具有未知权限的证书。如果名称不匹配,则会失败。
  • 证书应该与名称一起使用,默认情况下 chef-server 使用机器本地主机名生成证书。您应该修复您的 dns 并使用名称联系您的服务器,将 IP 添加到自签名证书中是一个坏主意。

标签: chef-infra knife


【解决方案1】:

为了回应 Tensibai 在 cmets 中所说的,验证模式仅控制根据受信任的 CA 数据库检查服务器证书,以检查该证书是否应受信任。即使在none 验证模式下(你真的不应该使用它),证书仍然必须匹配请求的主机名。

默认情况下,Chef Server 使用安装它的机器的 FQDN 生成自签名证书。

【讨论】:

    【解决方案2】:

    首先,如果不验证 ssl 我没问题,这应该与 --node-ssl-verify-mode none 一起使用,但有些原因它没有在 client.rb 中添加 ssl_verify_mode :verify_none 并且厨师客户端仍在尝试进行 ssl 验证。(所以我假设它可能是刀引导程序中的错误)

    所以我通过使用 --bootstrap-template 解决了上述问题

    knife ec2 server create -E $environment --node-name $TMP_NODE_NAME -f $instance_type -r "recipe[base]" --iam-profile $recipe --bootstrap-template ~/.chef/chef-no-ssl.erb $knife_ec2_flag
    

    ~/.chef/chef-no-ssl.erb

    bash -c '
    <%= "export https_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
    
    distro=`uname -s`
    
    if test "x$distro" = "xSunOS"; then
      if test -d "/usr/sfw/bin"; then
        PATH=/usr/sfw/bin:$PATH
        export PATH
      fi
    fi
    
    exists() {
      if command -v $1 &>/dev/null
      then
        return 0
      else
        return 1
      fi
    }
    
    install_sh="https://www.getchef.com/chef/install.sh"
    version_string="-v 12.19.36"
    
    if ! exists /usr/bin/chef-client; then
      echo "Installing Chef Client..."
      if exists wget; then
        bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -) ${version_string}
      elif exists curl; then
        bash <(curl -L <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> ${install_sh}) ${version_string}
      else
        echo "Neither wget nor curl found. Please install one and try again." >&2
        exit 1
      fi
    fi
    
    mkdir -p /etc/chef
    
    cat > /etc/chef/validation.pem <<'EOP'
    <%= validation_key %>
    EOP
    chmod 0600 /etc/chef/validation.pem
    
    <% if encrypted_data_bag_secret -%>
    cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
    <%= encrypted_data_bag_secret %>
    EOP
    chmod 0600 /etc/chef/encrypted_data_bag_secret
    <% end -%>
    
    <%# Generate Ohai Hints -%>
    <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
    mkdir -p /etc/chef/ohai/hints
    
    <% @chef_config[:knife][:hints].each do |name, hash| -%>
    cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
    <%= hash.to_json %>
    EOP
    <% end -%>
    <% end -%>
    
    cat > /etc/chef/client.rb <<'EOP'
    <%= config_content.concat "\nssl_verify_mode :verify_none" %>
    EOP
    
    cat > /etc/chef/first-boot.json <<'EOP'
    <%= first_boot.to_json %>
    EOP
    
    echo "Starting first Chef Client run..."
    
    <%= start_chef %>'
    

    所以如果你注意到最后有我正在连接的 client.rb 块

    cat > /etc/chef/client.rb <<'EOP'
    <%= config_content.concat "\nssl_verify_mode :verify_none" %>
    EOP
    

    【讨论】:

      猜你喜欢
      • 2017-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多