1

まず、私が得ているエラーは次のとおりです。

There are errors in the configuration of this machine. Please fix
the following errors and try again:

chef client provisioner:
* Chef server URL must be populated.
* Validation key path must be valid path to your chef server validation key.

シェフ サーバーの URL は入力されているように見え、検証キーのパスは有効です。

有効な 3 つの Vagrantfile があり、ドキュメントを使用して正しい順序を取得しようとしています。

これは、プロジェクト ディレクトリの 1 つの Vagrantfile にすべてを貼り付けるとうまく機能しますが、デフォルトを設定したいので、すべてをコピー ペーストする必要はありません。

1) ボックスに同梱されている Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.provider :vsphere do |vsphere|
    vsphere.host = 'vsphereserver.example.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" do |chef|
    chef.add_role "base"
    chef.provisioning_path = "/etc/chef"
    chef.chef_server_url = "https://chefserver.example.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
  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 = 'chefnode1'
    vsphere.name = 'chefnode1'
  end

  config.vm.provision "chef_client" do |chef|
    chef.node_name = "chefnode1"
    chef.add_role "test"
  end

end

どういうわけかchef_client構成全体を上書きしていますか? もしそうなら、どうすればそれをくっつけてマージすることができますか?

アップデート:

Tejay's answer とthis docで動作するものがありますが、別の構文に変換する必要があり、翻訳されたようなメソッドを取得する方法がわかりませんadd_role。これが私が持っているものです:

2)

  config.vm.provision "chef_client",
    id: "chef",
    provisioning_path: "/etc/chef",
    chef_server_url: "https://chefserver.example.com",
    validation_key_path: "/home/user/.vagrant.d/chef/validation.pem",
    client_key_path: "/etc/chef/client.pem",
    validation_client_name: "chef-validator",
    custom_config_path: "/home/user/.vagrant.d/Vagrantfile.chef",
    delete_node: true,
    delete_client: true

3)

  config.vm.provision "chef_client",
    id: "chef",
    node_name: "chefnode1"

これでマシンが起動しますが、run_list を指定できません。

4

1 に答える 1