找不到供应商

provisioner could not be found

我是 vagrant 的新手,我正在尝试启动一个名为 'haproxy' 的 vagrant box 并使用 ansible 来部署东西。我的 vagrant 文件如下:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.ssh.insert_key = false
  config.vm.define "haproxy" do |haproxy|
    config.vm.provision "haproxy" do |haproxy|
      ansible.verbose = "v"
      ansible.playbook = "Ansible_BASES/haproxy.yml"
  end
  end
end

但这表示:

viper@nishstorm:~/Vagrant_TEST$ vagrant up 
Bringing machine 'haproxy' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The 'haproxy' provisioner could not be found.

首先你不能调用供应商|haproxy|,供应商是strictly defined,你必须从已知供应商中声明一个供应商。在这里你的供应商是 ansible 已经暗示了 then 变量 ansible.verbose.

如果目的是让供应商与您的虚拟机一起工作,名称为 'haproxy',您可以按如下方式定义 Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.name = "haproxy"
  config.ssh.insert_key = false
  config.vm.provision "ansible" do |ansible|
    ansible.verbose = "v"
    ansible.playbook = "Ansible_BASES/haproxy.yml"
  end
end

不过你也可以这样做:

Vagrant.configure("2") do |config|
  config.vm.define 'haproxy' do |haproxy|
    haproxy.vm.box = "ubuntu/trusty64"
    haproxy.ssh.insert_key = false
    haproxy.vm.provision "ansible" do |ansible|
      ansible.verbose = "v"
      ansible.playbook = "Ansible_BASES/haproxy.yml"
    end
  end
end

安装配置插件可能会有帮助

vagrant plugin install vagrant provision