Set up 3 VMs ubuntu with vagrant
/ 1 min read
Table of Contents
Summary
In this post I will show you how we can set up 3 VMs with vagrant
Getting started
Setting dependencies
Verify vagrant
$ vagrant -vIn this post version of grant is Vagrant 2.2.18 and Virtual Box is 6.1.26
Solution
- Go to working directory
$ cd ~/ && mkdir ubuntu-vm && cd ubuntu-vm- Init Vagrant config
$ vagrant init- Update Vagrant config
Because I will set up 3 VMs ubuntu so you can follow the config file like that:
Vagrant.configure("2") do |config| config.vm.provision "shell", inline: <<-SHELL apt-get update SHELL (1..3).each do |i| config.vm.define "machine#{i}" do |machine| machine.vm.box = "hashicorp/bionic64" machine.vm.box_version = "1.0.282" machine.vm.network "private_network", ip: "192.168.0.10#{i}" machine.vm.provider "virtualbox" do |vb| vb.memory = "1024" vb.cpus = 1 end end endendYou can read more vagrant docs and some tips and tricks
- Start VM with vagrant cli
$ vagrant up- Verify
After vagrant up you can verify by access to VM. default user and password to access VM are vagrant
$ ssh vagrant@192.168.0.101$ ssh vagrant@192.168.0.102$ ssh vagrant@192.168.0.103