So far we have come across:
AnnouncementYou can find all my latest posts on medium.
# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box ="puppetlabs/ubuntu-14.04-32-nocm" end
Using “config.vm.box” means that your vagrantfile is limited to be able to only spin up a single box.
However instead of “config.vm.box” we could use the “config.vm.define”
# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.define "puppetmaster" do |puppetmaster| puppetmaster.vm.box ="puppetlabs/ubuntu-14.04-32-nocm" end end
this approach lets us label each box with a name that is used internally within the vagrant file, in this case I labelled it “puppetmaster”.
If you do a “vagrant up” for both of the above boxes, then the end result is the same, however with the “config.vm.define” approach it leaves the door open to add other boxes in future.
that’s why it’s best practice to always use the “config.vm.define” instead of “config.vm.box”.
Follow along from the same pattern we end up with:
Notice the “puppetmaster.vm.provider” pattern.
Note we have replaced the word “config” with our label. But if you want to look anything up in vagrant docs for “puppetmaster.vm.provider”, then you need to look for “config.vm.provider”. For example search for “config.vm.provider” on the follwoing page: