[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Build your own verification environment with Vagrant

My name is Ito and I am an infrastructure engineer.

It is commonplace in this world that we do not touch the customer's environment.
Normally, you should prepare a similar verification environment and perform verification there, but if you
messed with the production environment without permission and something happened, you are a disqualified infrastructure engineer! That's right.

Vagrant which we will introduce this time
is a tool that allows you to easily prepare a virtual verification environment that would be troublesome to prepare

Installation instructions

Let's install Vagrant.

Installing VirtualBox

Vagrant requires software called VitrualBox that can start a virtual OS on the OS.

Download VirtualBox from the following site.
Downloads – Oracle VM VirtualBox

vitrualbox_dl

I think there will be no problems if you follow the installer.
If you are unsure about the installation procedure, please refer to the following site.
Install VirtualBox on Windows | VirtualBox Mania

Installing Vagrant

Next is the installation of Vagrant.
Download from the site below.
Download - Vagrant by HashiCorp

vagrant_dl

As with VirtualBox, if you are unsure about the installation procedure, please refer to the following site.
Steps to install Vagrant on Windows | WEB ARCH LABO

After installation, try entering the following command at the command prompt.
You should see the version of Vagrant.

C:Userstest>vagrant --version Vagrant 1.7.4

Try starting up a virtual environment

Let's actually start up a virtual environment using Vagrant.
Vagrant downloads a disk image called "box" and
creates the box file as a virtual environment according to the configuration file.

box file can be obtained from below.
Official: Discover Vagrant Boxes | Atlas by HashiCorpUnofficial
: A list of base boxes for Vagrant - Vagrantbox.esActually
, I think you often use the unofficial vagrantbox.es.

By the way, you can also create your own box file.

First, let's download the box file.

vagrant box add<boxの名前><boxのURL>

It will look like this. Download the centos7 box file with the name centos70.

$ vagrant box add centos70 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box ==> box: Box file was not detected as metadata . Adding it directly... ==> box: Adding box 'centos70' (v0) for provider: box: Downloading: https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1 .0/centos-7.0-x86_64.box box: ==> box: Successfully added box 'centos70' (v0) for 'virtualbox'!

Check if box is downloaded.

$ vagrant box list centos70 (virtualbox, 0)

You can confirm that a box named "centos70" has been downloaded.

Next, create a definition file based on box.
A virtual server will be started based on this definition file.

$ vagrant init centos70 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.

A definition file called "Vagrantfile" will be created in the current directory.
By configuring this definition file, you can start a virtual server with various settings.

Now it's time to start up the virtual server.
It loads the settings in Vagrantfile and starts up.

$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'centos70'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: centos7_default_1455040381652_22475 ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Connection timeout. Retrying. .. default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => D:/system/cygwin64/home/itou/centos7

I'll try connecting.

$ vagrant ssh Last login: Sat May 30 12:27:44 2015 from 10.0.2.2 Welcome to your Vagrant-built virtual machine. [vagrant@localhost ~]$

Done!

In addition to the commands listed above, frequently used commands are listed below.

#Stop Vagrant vagrant halt #Reload Vagrantfile (restart) vagrant reload #Discard Vagrant (throw away the created virtual server) vagrant destroy #Check Vagrant status vagrant status

summary

The above is a simple way to build a verification environment using Vagrant!
The only thing that takes the most time is downloading the box file.

I think the company has default settings on the server.
The virtual environment with such settings added can be made into a box file, so
there is no need to perform the same operations for each verification environment.

Also, by using Vagrantfile, you
can easily configure port forwarding, set private IP addresses, and launch multiple virtual environments.
If you can master this area, you will be able to easily build complex environments.

Everyone, please use Vagrant to build a good verification environment!

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
1,022
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author