Video Link HERE
We have a lot of VirtualMachines to manage and we don't want to do that manually We need some sort of a tool to help us with that.
Follow the docs
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "base"
end
Vagrant.configure("2") do |config|
config.vm.box = "debian/buster64"
config.vm.define "nginx" do |nginx|
nginx.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
nginx.vm.network "private_network", ip: "192.168.33.10"
nginx.vm.hostname = 'nginx'
nginx.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y nginx
SHELL
end
config.vm.define "apache" do |apache|
apache.vm.provider "virtualbox" do |vb|
vb.memory = "512"
end
apache.vm.network "private_network", ip: "192.168.33.11"
apache.vm.hostname = 'apache'
apache.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y apache2
SHELL
end
end
Note: If you want to make it work with Windows, you need to do some hacks Use google if you would like to do that
Vagrant.configure("2") do |config|
config.vm.box = "debian/buster64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
# Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
---
- hosts: all
tasks:
- name: Install nginx
apt:
name: nginx
state: installed