Skip to content

iambotcoder/Vagrant-multi-VM-provisioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

🖥️ Multi-VM Vagrant Setup (Ubuntu & CentOS)


📖 Overview

This project demonstrates a multi-VM environment using Vagrant.
It provisions:

  1. web01 (Ubuntu) - Web Server
  2. db01 (CentOS) - Database Server

Both VMs are configured with private networks and provisioned automatically.


📑 Table of Contents


🔑 Prerequisites

Before you start, ensure you have the following installed:

  • Vagrant (latest version)
  • VirtualBox or any other supported provider

🏗️ Architecture

This project sets up a multi-VM environment:

VM Name OS IP Address Purpose
web01 Ubuntu 192.168.56.41 Web Server
db01 CentOS 9 192.168.56.44 Database Server

🛠️ Setup & Installation

1⃣ Initialize Vagrant:

vagrant init

🐾 Vagrant Setup 🖥️

Below is the Vagrantfile configuration used for this project:

Vagrant.configure("2") do |config|
    config.vm.define "web01" do |web01|
      web01.vm.box = "ubuntu/jammy64"
      web01.vm.hostname = "web01"
      web01.vm.network "private_network", ip: "192.168.56.41"
      web01.ssh.insert_key = false
      web01.ssh.private_key_path = "~/.vagrant.d/insecure_private_key"
    end
  
    config.vm.define "db01" do |db01|
      db01.vm.box = "eurolinux-vagrant/centos-stream-9"
      db01.vm.hostname = "db01"
      db01.vm.network "private_network", ip: "192.168.56.44"
      db01.ssh.insert_key = false
      db01.ssh.private_key_path = "~/.vagrant.d/insecure_private_key"
      db01.vm.provision "shell", inline: <<-SHELL
        yum install -y wget unzip mariadb-server -y
        systemctl start mariadb
        systemctl enable mariadb
      SHELL
    end
  end

2⃣ Start the Virtual Machine:

vagrant up

3⃣ Check VM Status:

vagrant status

4⃣ SSH into the VM:

vagrant ssh web01
vagrant ssh db01

5⃣ Check Network Configuration:

ip addr show
systemctl status mariadb  # (on db01 to check MariaDB status)

6⃣ Exit the VM:

exit

🧹 Cleaning Up Resources

To remove the VM and free up system resources, run the following commands in order:

1⃣ Destroy the Virtual Machine:

vagrant destroy

2⃣ Remove Unused Vagrant Instances:

vagrant global-status --prune

✅ Conclusion

This project automates a multi-VM setup with Ubuntu (Web Server) and CentOS (Database Server). It provides a quick and reproducible environment for testing and development.


👨‍🏫 Instructor

This project was guided by Imran Teli, who provided valuable mentorship throughout the process.

About

This project involves multi-VM provisioning using Vagrant.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published