An open API service indexing awesome lists of open source software.

https://github.com/iambotcoder/vagrant-automation-centos

This project automates Virtual Machine (VM) provisioning using Vagrant with CentOS Stream 9.
https://github.com/iambotcoder/vagrant-automation-centos

Last synced: 5 months ago
JSON representation

This project automates Virtual Machine (VM) provisioning using Vagrant with CentOS Stream 9.

Awesome Lists containing this project

README

          

# ๐Ÿ–ฅ๏ธ Vagrant Automation - CentOS Stream 9

---

## ๐Ÿ“– Overview

This project automates Virtual Machine (VM) provisioning using Vagrant with CentOS Stream 9. It simplifies the process of setting up a virtualized development environment with predefined configurations.

---

## ๐Ÿ“‘ Table of Contents

- [Prerequisites](#prerequisites) ๐Ÿ”‘
- [Architecture](#architecture) ๐Ÿ—๏ธ
- [Setup & Installation](#setup--installation) ๐Ÿ› ๏ธ
- [Vagrant Setup](#vagrant-setup) ๐Ÿพ
- [Cleaning Up Resources](#cleaning-up-resources) ๐Ÿงน
- [Conclusion](#conclusion) โœ…

---

## ๐Ÿ”‘ Prerequisites

Before you start, ensure you have the following installed:

- [Vagrant](https://www.vagrantup.com/downloads)
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
- Basic understanding of Linux and virtualization

---

## ๐Ÿ—๏ธ Architecture

This project uses Vagrant to automate VM provisioning with the following configurations:

- **OS**: CentOS Stream 9
- **Networking**: Private network with IP `192.168.56.14`
- **Resources**: 1600MB RAM, 2 CPU cores
- **SSH Configuration**: Custom SSH key setup
- **Provisioning (optional)**: Install and configure Apache web server

---

## ๐Ÿ› ๏ธ Setup & Installation

### 1โƒฃ Initialize Vagrant:
```bash
vagrant init eurolinux-vagrant/centos-stream-9
```

## ๐Ÿพ Vagrant Setup ๐Ÿ–ฅ๏ธ

Below is the `Vagrantfile` configuration used:

```ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
# Use the CentOS Stream 9 box
config.vm.box = "eurolinux-vagrant/centos-stream-9"

# Private network for host-only access (you can modify the IP)
config.vm.network "private_network", ip: "192.168.56.14"

# Synced folder from host to guest
# config.vm.synced_folder "D:\\scripts\\shellscripts", "/opt/scripts", type: "virtualbox"

# VirtualBox provider-specific configurations
config.vm.provider "virtualbox" do |vb|
# Allocate memory and CPUs
vb.memory = "1600"
vb.cpus = 2
vb.gui = false # Run the VM in headless mode (without GUI)
end

# Disable the default insecure SSH key and use newly generated keys
config.ssh.insert_key = false

# Ensure SSH keys are properly configured
config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key"

# Provision the VM with necessary updates and package installations
#config.vm.provision "shell", inline: <<-SHELL
# Update and install necessary packages
# You can comment below commands to just have a simple Centos standard VM
sudo dnf -y update
sudo dnf -y install httpd
sudo systemctl enable httpd
sudo systemctl start httpd
#SHELL
end

```

### 2โƒฃ Start the Virtual Machine:
```bash
vagrant up
```

### 3โƒฃ Check VM Status:
```bash
vagrant status
```

### 4โƒฃ SSH into the VM:
```bash
vagrant ssh
```

### 5โƒฃ Check Network Configuration:
```bash
ip addr show
```

### 6โƒฃ Exit the VM:
```bash
exit
```

### ๐Ÿงน Cleaning Up Resources

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

### 1โƒฃ Destroy the Virtual Machine:
```bash
vagrant destroy
```
### 2โƒฃ Remove Unused Vagrant Instances:
```bash
vagrant global-status --prune
```
---

## โœ… Conclusion

This project demonstrates how to automate VM provisioning using Vagrant and VirtualBox, making it easier to manage development and testing environments efficiently.

---

## ๐Ÿ‘จโ€๐Ÿซ Instructor

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