Vagrant を使用してシェフ ノードを作成していますが、イメージがスピンアップし、最初のシェフ クライアントの実行が失敗します。マシンに ssh して を削除/etc/chef/client.pem
し、再度実行sudo chef-client
すると成功しますが、vagrant から渡した run_list はありません。これは、失敗の様子です。
$ vagrant up
Bringing machine 'default' up with 'vsphere' provider...
==> default: Calling vSphere CloneVM with the following settings:
==> default: -- Template VM: myOrg/vm/myFolder/vagrantchefnode
==> default: -- Target VM: myOrg/vm/myFolder/test2
==> default: Waiting for SSH to become available...
==> default: New virtual machine successfully cloned and started
==> default: Rsyncing folder: /home/user/.vagrant.d/boxes/test2/ => /vagrant
==> default: Running provisioner: chef_client...
==> default: Creating folder to hold client key...
==> default: Uploading chef client validation key...
Generating chef JSON and uploading...
==> default: Running chef-client...
==> default: stdin: is not a tty
==> default: [2014-10-02T16:11:19-05:00] INFO: Forking chef instance to converge...
==> default: [2014-10-02T16:11:19-05:00] INFO: *** Chef 11.16.2 ***
==> default: [2014-10-02T16:11:19-05:00] INFO: Chef-client pid: 6080
==> default: [2014-10-02T16:11:21-05:00] INFO: HTTP Request Returned 401 Unauthorized: error
==> default: Failed to authenticate to the chef server (http 401).
==> default: Failed to authenticate as 'test2'. Ensure that your node_name and client key are correct.
==> default: chef_server_url "https://server.myorg.com"
==> default: node_name "test2"
==> default: client_key "/etc/chef/client.pem"
これらは私のVagrantfilesです:
1) ボックスに同梱されている Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :vsphere do |vsphere|
vsphere.host = 'vsphereserver.myorg.com'
vsphere.compute_resource_name = 'TestDev'
vsphere.user = 'vagrantadmin'
vsphere.password = 'password'
vsphere.insecure = true
end
config.ssh.username = 'auto'
config.ssh.private_key_path = '~/.vagrant.d/id_rsa'
end
2) ホーム ディレクトリ (~/.vagrant.d) の Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = 'vsphere'
config.vm.provider :vsphere do |vsphere|
vsphere.template_name = 'vagrantchefnode'
end
config.vm.provision "chef_client", id: "chef" do |chef|
chef.provisioning_path = "/etc/chef"
chef.chef_server_url = "https://chefserver.myorg.com"
chef.validation_key_path = "/home/user/.vagrant.d/chef/validation.pem"
# chef.client_key_path = "/etc/chef/client.pem"
chef.validation_client_name = "chef-validator"
chef.custom_config_path = "/home/user/.vagrant.d/Vagrantfile.chef"
chef.delete_node = true
chef.delete_client = true
chef.add_role "base"
end
end
3) プロジェクト ディレクトリの Vagrantfile (~/.vagrant.d/boxes/chefnode1):
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :vsphere do |vsphere|
# vsphere.template_name = 'chefnode'
vsphere.customization_spec_name = 'test2'
vsphere.name = 'test2'
end
config.vm.provision "chef_client", id: "chef" do |chef|
chef.node_name = "test2"
chef.add_role "dev"
end
end
2 番目の Vagrantfile で、chef.client_key_path のコメントを外してみましたが、効果はありませんでした。これは、すべてを 1 つの Vagrantfile にまとめたときに問題なく動作するように見えましたが、すべての設定を各 Vagrantfile にコピーせずに複数のマシンを実行したいと考えています。
--debug タグ付きの完全なログがあります。必要に応じて。