set setting reset

脂肪と糖にはたらくやつ

ドメイン参加した Windows Server で chef-client が動かない

状況

ドメイン参加前に knife bootstrap でプロビジョニング済みの windows server を、
新規構築した Active Directoryドメイン参加させた後に chef-client がエラーになる。

$ bundle exec knife winrm -m ${ip_addr} -x ${user_name} "c:\opscode\chef\bin\chef-client" -P ${password}

INFO: *** Chef 11.16.0 ***
INFO: Chef-client pid: 3172
INFO: HTTP Request Returned 401 Unauthorized: error

================================================================================
Chef encountered an error attempting to load the node data for "web-1.example.com"
================================================================================

Authentication Error:
---------------------
Failed to authenticate to the chef server (http 401).

Server Response:
----------------
Invalid signature for user or client 'web-1.example.com'

Relevant Config Settings:
-------------------------
chef_server_url   "https://chef-server"
node_name         "web-1.example.com"
client_key        "c:/chef/client.pem"

If these settings are correct, your client_key may be invalid, or
you may have a chef user with the same client name as this node.

FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
FATAL: Net::HTTPServerException: 401 "Unauthorized"

鍵が違うって言われる。

fqdn が変わってた

ドメイン参加前の node_name は web-1ドメイン参加後は web-1.example.com となっていました。
ちゃんと調べていませんが、ohai コマンドの fqdn を見ているのかもしれません。

client.pem を更新する

鍵が違うということなので更新してみます。
chef-server の webui からだと簡単にできそうです。

コマンドラインの場合は以下の様な感じです。

  • knife node edit 旧ホスト名name を編集して保存
  • knife client edit 旧ホスト名name を編集して保存
  • knife client reregister 旧ホスト名 で表示された公開鍵をコピー
  • windows server の c:\chef\client.pem を上書きする