How to Install Vagrant on ECS Ubuntu 18.04

How does vagrant works?

Prerequisites

$ sudo apt install virtualbox
[sudo] password for alain:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
adwaita-icon-theme at-spi2-core binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7
dconf-gsettings-backend dconf-service dkms dpkg-dev fakeroot fontconfig fontconfig-config fonts-dejavu-core g++
g++-7 gcc gcc-7 gcc-7-base glib-networking glib-networking-common glib-networking-services
gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libasound2 libasound2-data libasyncns0
.....
.....
Need to get 84.6 MB/112 MB of archives.
After this operation, 606 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
$ vboxmanage --version 
5.2.18_Ubuntur123745
$ wget https://download.virtualbox.org/virtualbox/5.2.26/virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb
--2019-03-20 16:36:35-- https://download.virtualbox.org/virtualbox/5.2.26/virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb
Resolving download.virtualbox.org (download.virtualbox.org)... 2.18.2.135
Connecting to download.virtualbox.org (download.virtualbox.org)|2.18.2.135|:443... connected.
HTTP request sent, awaiting response... 200 OK
...
...
$ sudo dpkg -i virtualbox-5.2_5.2.26-128414~Ubuntu~bionic_amd64.deb

Install Vagrant

$ sudo apt install vagrant
[sudo] password for alain:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
attr augeas-lenses bsdtar cpu-checker db-util db5.3-util exfat-fuse exfat-utils extlinux fonts-droid-fallback
fonts-lato fonts-noto-mono genisoimage ghostscript gsfonts gstreamer1.0-plugins-base gstreamer1.0-plugins-good
gstreamer1.0-x hfsplus ibverbs-providers icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms javascript-common
keyutils ldmtool libaa1 libafflib0v5 libaio1 libarchive-tools libarchive13 libaugeas0 libauthen-sasl-perl
....
....
Need to get 65.0 MB of archives.
After this operation, 271 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Create a Vagrant Machine

~/vagrant-machine$ vagrant init debian/stretch64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
~/vagrant-machine$ ls
Vagrantfile

Understanding the Lines of the Vagrantfile

Running the Vagrant Machine

~/vagrant-machine$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'debian/stretch64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'debian/stretch64'
default: URL: https://vagrantcloud.com/debian/stretch64
==> default: Adding box 'debian/stretch64' (v9.8.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/debian/boxes/stretch64/versions/9.8.0/providers/virtualbox.box
==> default: Successfully added box 'debian/stretch64' (v9.8.0) for 'virtualbox'!
==> default: Importing base box 'debian/stretch64'...
...
No usable default provider could be found for your system.Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
$ vagrant ssh
Linux stretch 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3 (2019-02-02) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
vagrant@stretch:~$
You can try an update
vagrant@stretch:~$ sudo apt update
Hit:1 http://security.debian.org/debian-security stretch/updates InRelease
Ign:2 http://deb.debian.org/debian stretch InRelease
Hit:3 http://deb.debian.org/debian stretch Release
Reading package lists... Done
Building dependency tree
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.
vagrant@stretch:~$ exit

Some Important Vagrant Commands

Creating a Vagrant Machine from an Existing Box in Your Computer

$ vagrant box add centos/7
==> box: Loading metadata for box 'centos/7'
box: URL: https://vagrantcloud.com/centos/7
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) hyperv
2) libvirt
3) virtualbox
4) vmware_desktop
Enter your choice: 3
==> box: Adding box 'centos/7' (v1902.01) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box
$ mkdir centos7 && cd centos7
$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1902.01' is up to date...
==> default: Setting the name of the VM: centos7_default_1553955605013_87107
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
....
....
==> default: Machine booted and ready!
....
[vagrant@localhost ~]$ sudo yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirror.wiru.co.za
* extras: mirror.wiru.co.za
* updates: www.ftp.saix.net
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): base/7/x86_64/group_gz | 166 kB 00:01
(2/4): extras/7/x86_64/primary_db | 187 kB 00:01
(3/4): base/7/x86_64/primary_db | 6.0 MB 00:07
(4/4): updates/7/x86_64/primary_db | 3.4 MB 00:16
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.12.0-8.el7_6 will be updated
---> Package NetworkManager.x86_64 1:1.12.0-10.el7_6 will be an update
---> Package NetworkManager-libnm.x86_64 1:1.12.0-8.el7_6 will be updated
...
...

Original Source

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

About Me — Rick Buiten

Dynamically Generating DB Credentials via Vault

Java 8 | StringTokenizer Practice 2

Instant VM Recovery from Backup

The Technologies Behind Taobao Live Streaming

Family Who Invited Wrong Person to Thanksgiving Dinner Every Year Honors Husband Who Died of…

4 Reasons why you need an augmented data integration tool

Extending the TDD cycle

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Efficient CPU-intensive GRPC service in Python — Part 2

Docker based Postgres DB — docker-compose.yaml

Collect and Store Events from Kafka with InfluxDB and Telegraf using Docker

gRPC rocks build your first gRPC service(part 1)