In this blog, we are going to create 2 Ubuntu machines with private IP addresses that will be accessible from the host. Before that, if you are new to Vagrant tool, Vagrant is a tool for creating and managing portable, reproducible development environments. It simplifies the process of setting up virtual machines for different projects, ensuring consistency and efficiency.
How Vagrant tool help to learn DevOps Faster?
Understanding virtualization: Creating isolated environments.
Practicing IaC: Defining and managing infrastructure with code.
Integrating configuration management: Using tools like Ansible, Chef, or Puppet.
Collaborating with team members: Sharing development environments.
Experimenting safely: Testing new technologies without affecting production.
Access Git command on your Windows, point to the location where you want to create this project. Create directory using command mkdir
Note that currently this directory is empty
Run vagrant init to initialize vagrant, this will create Vagrant file which is kind of a template that you can modify according to your requirements
Open Vagrantfile using Notepad; note that we are planning to create 2 VMs with static IP addresses that we can access from the host. Delete the old code and replace with below:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "ansiblesvr" do |ansiblesvr|
ansiblesvr.vm.box = "ubuntu/trusty64"
ansiblesvr.vm.hostname = "ansible-server"
ansiblesvr.vm.network :private_network, ip: "192.168.56.10"
end
config.vm.define "ansibleclt" do |ansibleclt|
ansibleclt.vm.box = "ubuntu/trusty64"
ansibleclt.vm.hostname = "ansible-client"
ansibleclt.vm.network :private_network, ip: "192.168.56.20"
end
end
After few minutes the machines will show up in Virtual Box
You can connect to these machines via putty using their host names / private IP addresses configured in Vagrant file
This article explains how to use Vagrant, a tool for building and managing virtual machine environments, to create Ubuntu virtual machines with static IP addresses. It details the configuration process in the Vagrantfile, including setting up network settings to ensure that each virtual machine has a static IP address. This setup is particularly useful for development environments that require stable network configurations for testing and integration.
Add a Comment