Search code examples
vagrantvagrantfile

provisioner could not be found


I am new to vagrant and i am trying to launch a vagrant box with the name 'haproxy' and using ansible to deploy stuff. my vagrant file is as follows:

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

But this says :

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.

Solution

  • First You can't call a provisioner |haproxy|, provisioner are strictly defined, you have to declare a provisioner from the known ones. Here your provisioner is ansible has implied by the then variable ansible.verbose.

    If the intent was to make the provisioner work with your a vm with the name 'haproxy' you can define your Vagrantfile as following:

    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
    

    But you can also do it like this:

    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