Background:
I've created a multi-machine setup with Vagrant which takes advantage of Ansible as the provisioner. It creates a nginx load balancer, varnish cache and then my application on three separate VM's. vagrant reload and vagrant provision are both showing the error '* A box must be specified.' despite the box being specified correctly.
The way I know this is that if you put in an invalid name you get the error 'The machine with the name 'applicationz' was not found configured for this Vagrant environment.'
vagrant destroy application, vagrant up application and vagrant ssh application all work -- but this obviously slows down iteration considerably when you just want to re-provision a VM with ansible.
Also be advised that with my current setup I BELIEVE that I've discovered the root cause -- which I believe to be ssh related.
When debugging ansible by running the manual command ' ansible-playbook application/playbook.yml -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=~/.ssh/id_rsa -vvvv' I see that the pubkey authentication fails at:
debug2: key: /Users/_/Sites/_/Projects/final/.vagrant/machines/application/virtualbox/private_key (0x0), explicit
which appears to have something to do with permissions. However manually altering permissions also doesn't appear to work. Be advised I'm using a CENTOS 6.7 box with all updated core packages (including openssh). Also be advised that I am able to manually ssh into the box with the correct ip/port and I am also able to use vagrant ssh application.
I am running Vagrant 1.7.4 and Ansible 1.7.2.
My configuration looks like this:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20131103.box"
#LoadBalancer
config.vm.define "lb" do |lb_config|
config.vm.box = "centos6"
lb_config.vm.hostname = "lala.nginx.lb"
# lb_config.hostmanager.enabled = true
lb_config.vm.network :private_network, ip: "10.0.1.11"
#set some machine-specific options
lb_config.vm.provision "ansible" do |ansible|
ansible.playbook = "nginx-lb/playbook.yml"
ansible.sudo = true
ansible.extra_vars = { ansible_ssh_user: 'vagrant',
ansible_connection: 'ssh',
ansible_ssh_args: '-o ForwardAgent=yes'}
end
end
#Varnish
config.vm.define "varnish" do |varnish_config|
config.vm.box = "centos6"
varnish_config.vm.hostname = "lala.varnish"
# varnish_config.hostmanager.enabled = true
varnish_config.vm.network :private_network, ip: "10.0.1.22"
#set some machine-specific options
varnish_config.vm.provision "ansible" do |ansible|
ansible.playbook = "varnish/playbook.yml"
ansible.sudo = true
ansible.extra_vars = { ansible_ssh_user: 'vagrant',
ansible_connection: 'ssh',
ansible_ssh_args: '-o ForwardAgent=yes'}
end
end
#Applicaiton
config.vm.define "application" do |application_config|
config.vm.box = "centos6"
application_config.vm.hostname = "lala.seed"
# application_config.hostmanager.enabled = true
application_config.vm.network :private_network, ip: "10.0.1.33"
#set some machine-specific options
application_config.vm.provision "ansible" do |ansible|
ansible.playbook = "application/playbook.yml"
ansible.sudo = true
ansible.extra_vars = { ansible_ssh_user: 'vagrant',
ansible_connection: 'ssh',
ansible_ssh_args: '-o ForwardAgent=yes'}
end
end
end
I am getting the same error. Full details can be viewed here: https://stackoverflow.com/questions/32442175/vagrant-config-error-a-box-must-be-specified
Hi @generalconsensus
Thank you for opening an issue, and I am sorry you are having issues with Vagrant. I see that you've shared your Vagrantfile - is that the complete Vagrantfile? Could you please share the output of the vagrant command in debug mode. Thanks! :smile:
You are setting config.vm.box instead of things such as lb_config.vm.box. Please use the correct config object and this will work! Sorry Vagrant doesn't catch this automatically. We've tried a few times but it is notoriously tricky.
Finding this 5 years later and its still an issue (online resources show using config.vm still in multi-vm setups) - learned something new, thanks @mitchellh
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
You are setting
config.vm.boxinstead of things such aslb_config.vm.box. Please use the correct config object and this will work! Sorry Vagrant doesn't catch this automatically. We've tried a few times but it is notoriously tricky.