Here’s how I used Vagrant.
I needed to create a Linux VM that I could thrash on, throw in the garbage, recreate it and trash some more. I was developing an Ansible deployment.
This tutorial assumes to things
If either of those two things is not true, you should make them true before continuing. If you don’t, what’s the point, right?
Create two files, one called Vagrant and another called inventory
I’ll assume you created a directory called “vagrant,” but it doesn’t matter what you call it, or if you use a special directory or not.
In the vagrant directory, create two files. You don’t actually have to do this. I’m just doing it to be verbose.
mkdir vagrant;cd vagrant;touch Vagrant;touch inventory
Edit Vagrant and make it look like this.
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # Configure Linux VM config.vm.box = "geerlingguy/centos7" config.ssh.insert_key = false config.vm.synced_folder '.', '/vagrant', disabled: true # Create VirtualBox Linux VM config.vm.provider :virtualbox do |v| v.memory = 512 v.cpus = 1 v.linked_clone = true v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] v.customize ["modifyvm", :id, "--ioapic", "on"] end # Apache. config.vm.define "apache" do |apache| apache.vm.provision "shell", inline: "sudo yum update -y" apache.vm.provider :virtualbox do |v| v.customize ["modifyvm", :id, "--memory", 256] end end
Now edit inventory so it looks like this.
Now run Vagrant to build out the Linux VM in VirtualBox.
After the VM is up, I then run my Ansible playbook on it to build out my application envrionment.