- Change ssh keys in script to yours before runnning script or comment the ssh line to avoid errors
This guide covers the setup of development environments using Vagrant with either Hyper-V or VirtualBox as the provider. Each environment configures multiple virtual machines (VMs) with Ubuntu, installs essential development tools, and sets up networking and SSH access.
Two Vagrantfile
scripts are provided:
- One for Hyper-V: Tailored for environments running on Windows with Hyper-V enabled.
- One for VirtualBox: Suitable for cross-platform use where VirtualBox is preferred or required.
Each script dynamically creates VMs, configures them with a private network, installs software packages such as Docker, Kubernetes CLI tools (kubectl
), HTTPD (Apache), and Curl. The first VM in each setup receives additional tools: Ansible, Terraform, and Vagrant.
- Configures VMs with Hyper-V.
- Names VMs using a convention based on their assigned IP addresses for easy identification.
- Applies a specific IP address to the first VM and sequential IP addresses to others.
- Configures VMs with VirtualBox.
- Utilizes two network adapters per VM for enhanced networking capabilities.
- Similar software installation and user setup as the Hyper-V script.
- For Hyper-V: Windows 10/11 Pro, Enterprise, or Education with Hyper-V enabled.
- For VirtualBox: Windows, macOS, or Linux with VirtualBox installed.
- General: Git (for cloning the repository) and Vagrant installed on your system.
-
Clone the Repository: Clone the GitHub repository containing the Vagrant scripts to your local machine.
git clone https://github.com/Liberace1/Deploy-VM.git cd Deploy-VM
-
Choose Your Provider:
- For Hyper-V, ensure Hyper-V is enabled on your system.
- For VirtualBox, ensure VirtualBox is installed.
-
Start the Vagrant Environment:
- Navigate to the directory containing the desired
Vagrantfile
(Hyper-V or VirtualBox). - Run the following command to initiate and provision the VMs:
or
vagrant up --provider=hyper-v # For Hyper-V
vagrant up # For VirtualBox (default provider)
- Navigate to the directory containing the desired
-
Accessing VMs:
- Use
vagrant ssh <vm-name>
to SSH into a specific VM. The VM names follow the convention defined in the respectiveVagrantfile
.
- Use
-
Stopping VMs:
- To halt the VMs without destroying them, use:
vagrant halt
- To halt the VMs without destroying them, use:
-
Cleaning Up:
- To permanently remove the VMs and clean up all resources, use:
vagrant destroy
- To permanently remove the VMs and clean up all resources, use:
vagrant up
: Starts and provisions the VM(s) according to theVagrantfile
.vagrant halt
: Stops the VM(s).vagrant reload
: Restarts and re-applies any changes to theVagrantfile
to the VM(s).vagrant ssh <vm-name>
: Connects to the VM via SSH.vagrant destroy
: Stops and deletes all resources created during the machine creation process.
You can customize the VM configurations, networking, and provisioned software by editing the Vagrantfile
. For detailed documentation on Vagrant's features and configuration options, visit the official Vagrant documentation.
Ensure you replace <repository-url>
and <repository-directory>
with the actual URL and directory name of the GitHub repository where your Vagrant scripts are stored. This README provides a comprehensive guide for users to set up, manage, and understand their Vagrant environments.