Windows 10 で Vagrant を使う¶
Vagrant とは¶
Oracle VritualBox や VMware Workstation などの仮想環境と組み合わせて使用し、仮想環境上に自動でサーバーを構築するツール
サーバー構築後に Ansible などの構成管理ツールやシェルスクリプトと連携し、アプリケーションなどのインストールや設定まで自動化が可能
Windows 、 macOS 、 Linux 用が提供されている
検証環境¶
Microsoft Windows 10 Pro Version 1909 (64-bit)
HashiCorp Vagrant 2.2.7 (Windows - 64-bit)
Orace VritualBox 6.1.2 (Windows hosts)
環境構築¶
Windows 上に Vagrant の実行環境を構築します。必要なアプリケーションです。
テキストエディタ
テキストエディタはサクラエディタなど、使い慣れたものを準備ください。
Oracle VirtualBox¶
Oracle VirtualBox をダンロード・インストールします。
ダウンロード¶
Windows hosts
をダウンロードします。
注釈
VirtualBox にとって Extension Pack はいろいろとメリットがあるのでお勧めです。
インストール¶
1. インストールファイルを起動¶

2. Next をクリック¶

3. Next をクリック¶

4. Next をクリック¶

5. Yes をクリック¶

6. Install をクリック¶

7. インストール中¶

8. インストール(I) をクリック¶

9. Finish をクリック¶

10. Oracle VirtualBox のインストールが終了¶

11. ファイル(F)
をクリック → 環境設定(P)...
をクリック¶

12. 拡張機能
をクリック → + をクリック¶

13. Extension Pack を選択 → 開く(O) をクリック¶

14. インストール をクリック¶

15. ライセンス条文を最後までスクロール → 同意します(A) をクリック¶

16. OK をクリック¶

17. Extension Pack が追加されたことを確認 → OK をクリック¶

Vagrant¶
Vagrant をダンロード・インストールします。
インストール¶
1. インストールファイルを起動¶

2. Next をクリック¶

3. I accept ・・・
にチェックを入れる → Next をクリック¶

4. Next をクリック¶

5. Install をクリック¶

6. インストール中¶

7. Finish をクリック¶

8. Yes をクリック¶

9. 再起動 → ログイン¶

10. コマンドプロンプトを起動 → バージョン確認¶
PS C:\Users\user> vagrant --version
Vagrant 2.2.7
PS C:\Users\user>
PS C:\Users\user> vagrant -v
Vagrant 2.2.7
PS C:\Users\user>
用語¶
Vagrant を使用するときの用語(キーワード)です。
プロバイダ¶
Oracle VirtualBox や VMware Workstation などの仮想環境を指します。
プロビジョニング¶
Ansible などの構成管理ツールやシェルスクリプトでアプリケーションのインストールや設定を行うことです。
Box ファイル¶
仮想マシンのイメージファイル。Vagrant Cloudや GitHub などから入手します。このファイルとVagrantfileを使用して仮想マシンを作成します。作成した仮想マシンを元に Box ファイルを作成できます。
Vagrant コマンド¶
Vagrant を操作するためのコマンドのことです。 バージョン確認で実行した"vagrant --version"も Vagrant コマンドです。
主な Vagrant コマンド¶
コマンドリスト¶
Box ファイルの操作¶
- vagrant box add
vagrant box add Boxファイル名
vagrant box add Boxファイル名 URL
vagrant box add Boxファイル名 path
Box ファイルをダウンロードする。
ダウンロード先を指定しない場合Vagrant Cloudからダウンロードする。
Vagrant Cloud 以外、例えば GitHub からダウンロードするときはダウンロード先の URL を指定する。
ダウンロード先を path で指定できるときはその path を指定する。
- vagrant box remove
vagrant box remove Boxファイル名
ダウンロードした Box ファイルから指定した Box ファイルを廃棄(削除)する。
- vagrant box list
vagrant box list
ダウンロード済みの Box ファイルを一覧で表示する。
仮想マシンの操作¶
- vagrant init
vagrant init Boxファイル名
指定した Box ファイル用の Vagrantfile が作成される。
- vagrant up
vagrant up
仮想マシンを起動する。
仮想マシンが作成されていないときは仮想マシンの作成 → 起動する。
Box ファイルがダウンロードしていないときはダウンロードする。
サスペンド状態の仮想マシンをリジュームする。
- vagrant halt
vagrant halt
仮想マシンを停止する。
- vagrant reload
vagrant reload
仮想マシンを再起動する。
- vagrant suspend
vagrant suspend
仮想マシンをサスペンドする。
- vagrant resume
vagrant resume
サスペンド状態の仮想マシンをリジュームする。
- vagrant package
vagrant package
仮想マシンから Box ファイルを作成する。
- vagrant destroy
vagrant destroy
仮想マシンを廃棄(削除)する。
- vagrant ssh
vagrant ssh
仮想マシンに ssh 接続する。
ヘルプ¶
ヘルプの表示方法
PS C:\Users\user> vagrant -h
Usage: vagrant [options] <command> [<args>]
-v, --version Print the version and exit.
-h, --help Print this help.
Common commands:
box manages boxes: installation, removal, etc.
cloud manages everything related to Vagrant Cloud
destroy stops and deletes all traces of the vagrant machine
global-status outputs status Vagrant environments for this user
halt stops the vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a Vagrantfile
login
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
port displays information about guest port mappings
powershell connects to machine via powershell remoting
provision provisions the vagrant machine
push deploys code in this environment to a configured destination
rdp connects to machine via RDP
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
snapshot manages snapshots: saving, restoring, etc.
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment
upload upload to machine via communicator
validate validates the Vagrantfile
version prints current and latest Vagrant version
winrm executes commands on a machine via WinRM
winrm-config outputs WinRM configuration to connect to the machine
For help on any individual command run `vagrant COMMAND -h`
Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
PS C:\Users\user>
PS C:\Users\user> vagrant box -h
Usage: vagrant box <subcommand> [<args>]
Available subcommands:
add
list
outdated
prune
remove
repackage
update
For help on any individual subcommand run `vagrant box <subcommand> -h`
PS C:\Users\user>
PS C:\Users\user> vagrant box add -h
Usage: vagrant box add [options] <name, url, or path>
Options:
-c, --clean Clean any temporary download files
-f, --force Overwrite an existing box if it exists
--insecure Do not validate SSL certificates
--cacert FILE CA certificate for SSL download
--capath DIR CA certificate directory for SSL download
--cert FILE A client SSL cert, if needed
--location-trusted Trust 'Location' header from HTTP redirects and use the same credentials for subsequent urls as for the initial one
--provider PROVIDER Provider the box should satisfy
--box-version VERSION Constrain version of the added box
The box descriptor can be the name of a box on HashiCorp's Vagrant Cloud,
or a URL, or a local .box file, or a local .json file containing
the catalog metadata.
The options below only apply if you're adding a box file directly,
and not using a Vagrant server or a box structured like 'user/box':
--checksum CHECKSUM Checksum for the box
--checksum-type TYPE Checksum type (md5, sha1, sha256)
--name BOX Name of the box
-h, --help Print this help
PS C:\Users\user>
ウォークスルー¶
Vagrant コマンドを実際に使用し、CentOS 7 の仮想マシンの作成から廃棄までを実行します。 Box ファイルは CentOS 公式の "centos/7" を使用します。
Box ファイルをダウンロード¶
仮想マシンを作成するため Box ファイル "centos/7" をダウンロードします。今回は途中でプロバイダを確認されたので "3) virtualbox" を選択しました。
vagrant box list
vagrant box add centos/7
vagrant box list
PS C:\Users\user> vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.
PS C:\Users\user>
PS C:\Users\user> 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' (v1905.1) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1905.1/providers/virtualbox.box
box: Download redirected to host: cloud.centos.org
box:
==> box: Successfully added box 'centos/7' (v1905.1) for 'virtualbox'!
PS C:\Users\user>
PS C:\Users\user> vagrant box list
centos/7 (virtualbox, 1905.1)
PS C:\Users\user>
注釈
Box ファイルのダウンロードはファイルのサイズや実行環境などにより数分程度を要します。
Vagrantfile を作成¶
作成したフォルダーで Vagrantfile を作成します。
cd c:\vagrant\centos7
vagrant init centos/7
PS C:\Users\user> cd C:\vagrant\centos7\
PS C:\vagrant\centos7>
PS C:\vagrant\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.
PS C:\vagrant\centos7>
フォルダー内に Vagrantfile が作成されました。

仮想マシンを起動¶
Box ファイルと Vagrant ファイルが揃ったので、仮想マシンを起動します。起動時のメッセージは仮想マシンの状態を示す内容が多く、接続時の参考になります。
vagrant up
PS C:\vagrant\centos7> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: centos7_default_1580909693985_35672
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Rsyncing folder: /cygdrive/c/vagrant/centos7/ => /vagrant
PS C:\vagrant\centos7>
プロンプトが表示された時点で VirtualBox は起動していないように見えますが、ヘッドレスモード(バックグラウンドで動作)しています。


Oracle VM VirtualBox マネージャーを起動すると、仮想マシンが動作していることがわかります。

仮想マシンに接続¶
仮想マシンが起動したので ssh 接続します。公開鍵認証で接続するためパスワードの入力は不要です。
vagrant ssh
PS C:\vagrant\centos7> vagrant ssh
[vagrant@localhost ~]$
[vagrant@localhost ~]$ hostname
localhost.localdomain
[vagrant@localhost ~]$
[vagrant@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86290sec preferred_lft 86290sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
[vagrant@localhost ~]$
[vagrant@localhost ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\centos7>
仮想マシンを再起動¶
仮想マシンを再起動します。
vagrant reload
出力されたメッセージで shutdown → boot していることがわかります。
PS C:\vagrant\centos7> vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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 (guest) => 2222 (host) (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 reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Rsyncing folder: /cygdrive/c/vagrant/centos7/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\centos7>
仮想マシンを停止(シャットダウン)¶
仮想マシンを停止(シャットダウン)します。
vagrant halt
PS C:\vagrant\centos7> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\centos7>
仮想マシンをサスペンド¶
稼働中の仮想マシンをサスペンドします。
vagrant suspend
PS C:\vagrant\centos7> vagrant suspend
==> default: Saving VM state and suspending execution...
PS C:\vagrant\centos7>
Oracle VM VirtualBox マネージャーで確認すると、仮想マシンがサスペンドしていることがわかります。

仮想マシンをリジューム¶
サスペンド状態の仮想マシンをリジュームします。リジュームするコマンドは 2 つあります。どちらを実行しても結果は同じです。
vagrant up
PS C:\vagrant\centos7> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Resuming suspended VM...
==> 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: Machine booted and ready!
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\centos7>
vagrant resume
PS C:\vagrant\centos7> vagrant resume
==> default: Resuming suspended VM...
==> 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: Machine booted and ready!
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\centos7>
仮想マシンの状態を表示¶
仮想マシンの状態( poweroff / running / saved )を表示します。
vagrant status
vagrant up
vagrant status
vagrant suspend
vagrant status
PS C:\vagrant\centos7> vagrant status
Current machine states:
default poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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 (guest) => 2222 (host) (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 aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection reset. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Rsyncing folder: /cygdrive/c/vagrant/centos7/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant suspend
==> default: Saving VM state and suspending execution...
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant status
Current machine states:
default saved (virtualbox)
To resume this VM, simply run `vagrant up`.
PS C:\vagrant\centos7>
仮想マシンを削除¶
仮想マシンを削除します。
vagrant destroy
PS C:\vagrant\centos7> vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
PS C:\vagrant\centos7>
Oracle VM VirtualBox マネージャーで確認すると、仮想マシンが削除されたことがわかります。

Box ファイルを削除¶
ダウンロードした Box ファイル "centos/7" を削除します。
vagrant box list
vagrant box remove centos/7
vagrant box list
PS C:\vagrant\centos7> vagrant box list
centos/7 (virtualbox, 1905.1)
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant box remove centos/7
Box 'centos/7' (v1905.1) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:
default (ID: ec6eabdbc2834c4c813ae0bde08edc95)
Are you sure you want to remove this box? [y/N] y
Removing box 'centos/7' (v1905.1) with provider 'virtualbox'...
PS C:\vagrant\centos7>
PS C:\vagrant\centos7> vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.
PS C:\vagrant\centos7>
デフォルトの仮想マシンの仕様¶
「ウォークスルー」で扱った Box ファイル "centos/7" で作成した仮想マシンを例に、vagrant で作成した仮想マシンの詳細を確認します。
【トピックス】
Vagrantfile の編集¶
Vagrantfile を編集し、オリジナルの仮想マシンを作成します。
オリジナルの Vagrantfile¶
vagrant init
コマンドで作成した Vagrantfile の内容です。 Box ファイルは "centos/7" です。
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "centos/7"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
コメントを除いた内容です。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
end
Vagrantfile の構造¶
Vagrantfile の構造です。
Vagrant.configure("2") do |config|
パラメーター
end
1 行目は Vagrant のどのバージョン用の Vagrantfile なのかを示します。現行の Vagrant は Ver.2 なので 1 行目は次のようになります。
Vagrant.configure("2") do |config|
主なパラメーター¶
config.vm.network¶
仮想マシンのネットワークへの接続形態や IPアドレスを指定します。
デフォルト(本パラメーターを指定しない)は NAT です。
接続形態別設定
ブリッジ接続 & DHCP
config.vm.network "public_network"
ブリッジ接続 & Static IP
config.vm.network "public_network", ip "192.168.0.1"
ブリッジ接続 & MAC アドレス指定
config.vm.network "public_network", mac: "080027000001"
ブリッジ接続 & MAC アドレス指定 & Static IP
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
内部ネットワーク & 内部ネットワーク名:intnet (デフォルト) & MAC アドレス指定 & Static IP
config.vm.network "private_network", mac: "080027000001", ip: "192.168.10.1", virtualbox__intnet: true
内部ネットワーク & 内部ネットワーク名:mynetwork & MAC アドレス指定 & Static IP
config.vm.network "private_network", mac: "080027000001", ip: "192.168.10.1", virtualbox__intnet: "mynetwork"
注意
VirtualBox の内部ネットワークは DHCP サーバーが存在しない( VirtualBox の仕様)ため、 Vagrantfile で static ip を設定する
VirtualBox の内部ネットワークの VM を起動後に手動で IP アドレスを指定しても Vagrantfile の設定で上書きされる
vb.gui¶
VirtualBox の起動モードを指定する。
指定がないときはヘッドレスモードで起動する。
GUI モードで起動(コンソールを起動)する。
config.vm.provider "virtualbox" do |vb|
vb.gui = true
end
vb.memory¶
仮想マシンのメモリサイズを MB (メガバイト)で指定します。
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
vb.cpu¶
仮想マシンの CPU の数を指定します。
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on"
]
end
vb.customize¶
仮想マシンのカスタマイズを指定します。
(たぶん)
VBoxManage.exe modifyvm
で設定できることはこのパラメーターで指定できる(と思う)。
config.vm.provider "virtualbox" do |vb|
vb.customize [
"modifyvm", :id,
"--graphicscontroller", "vmsvga"
]
end
PS C:\Program Files\Oracle\VirtualBox> ./VBoxManage.exe modifyvm
Usage:
VBoxManage modifyvm <uuid|vmname>
[--name <name>]
[--groups <group>, ...]
[--description <desc>]
[--ostype <ostype>]
[--iconfile <filename>]
[--memory <memorysize in MB>]
[--pagefusion on|off]
[--vram <vramsize in MB>]
[--acpi on|off]
[--ioapic on|off]
[--hpet on|off]
[--triplefaultreset on|off]
[--apic on|off]
[--x2apic on|off]
[--paravirtprovider none|default|legacy|minimal|
hyperv|kvm]
[--paravirtdebug <key=value> [,<key=value> ...]]
[--hwvirtex on|off]
[--nestedpaging on|off]
[--largepages on|off]
[--vtxvpid on|off]
[--vtxux on|off]
[--pae on|off]
[--longmode on|off]
[--ibpb-on-vm-exit on|off]
[--ibpb-on-vm-entry on|off]
[--spec-ctrl on|off]
[--l1d-flush-on-sched on|off]
[--l1d-flush-on-vm-entry on|off]
[--mds-clear-on-sched on|off]
[--mds-clear-on-vm-entry on|off]
[--nested-hw-virt on|off]
[--cpu-profile "host|Intel 80[86|286|386]"]
[--cpuid-portability-level <0..3>]
[--cpuid-set <leaf[:subleaf]> <eax> <ebx> <ecx> <edx>]
[--cpuid-remove <leaf[:subleaf]>]
[--cpuidremoveall]
[--hardwareuuid <uuid>]
[--cpus <number>]
[--cpuhotplug on|off]
[--plugcpu <id>]
[--unplugcpu <id>]
[--cpuexecutioncap <1-100>]
[--rtcuseutc on|off]
[--graphicscontroller none|vboxvga|vmsvga|vboxsvga]
[--monitorcount <number>]
[--accelerate3d on|off]
[--accelerate2dvideo on|off]
[--firmware bios|efi|efi32|efi64]
[--chipset ich9|piix3]
[--bioslogofadein on|off]
[--bioslogofadeout on|off]
[--bioslogodisplaytime <msec>]
[--bioslogoimagepath <imagepath>]
[--biosbootmenu disabled|menuonly|messageandmenu]
[--biosapic disabled|apic|x2apic]
[--biossystemtimeoffset <msec>]
[--biospxedebug on|off]
[--system-uuid-le on|off]
[--boot<1-4> none|floppy|dvd|disk|net>]
[--nic<1-N> none|null|nat|bridged|intnet|hostonly|
generic|natnetwork]
[--nictype<1-N> Am79C970A|Am79C973|Am79C960|
82540EM|82543GC|82545EM|
virtio]
[--cableconnected<1-N> on|off]
[--nictrace<1-N> on|off]
[--nictracefile<1-N> <filename>]
[--nicproperty<1-N> name=[value]]
[--nicspeed<1-N> <kbps>]
[--nicbootprio<1-N> <priority>]
[--nicpromisc<1-N> deny|allow-vms|allow-all]
[--nicbandwidthgroup<1-N> none|<name>]
[--bridgeadapter<1-N> none|<devicename>]
[--hostonlyadapter<1-N> none|<devicename>]
[--intnet<1-N> <network name>]
[--nat-network<1-N> <network name>]
[--nicgenericdrv<1-N> <driver>]
[--natnet<1-N> <network>|default]
[--natsettings<1-N> [<mtu>],[<socksnd>],
[<sockrcv>],[<tcpsnd>],
[<tcprcv>]]
[--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
<hostport>,[<guestip>],<guestport>]
[--natpf<1-N> delete <rulename>]
[--nattftpprefix<1-N> <prefix>]
[--nattftpfile<1-N> <file>]
[--nattftpserver<1-N> <ip>]
[--natbindip<1-N> <ip>]
[--natdnspassdomain<1-N> on|off]
[--natdnsproxy<1-N> on|off]
[--natdnshostresolver<1-N> on|off]
[--nataliasmode<1-N> default|[log],[proxyonly],
[sameports]]
[--macaddress<1-N> auto|<mac>]
[--mouse ps2|usb|usbtablet|usbmultitouch]
[--keyboard ps2|usb]
[--uart<1-N> off|<I/O base> <IRQ>]
[--uartmode<1-N> disconnected|
server <pipe>|
client <pipe>|
tcpserver <port>|
tcpclient <hostname:port>|
file <file>|
<devicename>]
[--uarttype<1-N> 16450|16550A|16750]
[--lpt<1-N> off|<I/O base> <IRQ>]
[--lptmode<1-N> <devicename>]
[--guestmemoryballoon <balloonsize in MB>]
[--vm-process-priority default|flat|low|normal|high]
[--audio none|null|dsound]
[--audioin on|off]
[--audioout on|off]
[--audiocontroller ac97|hda|sb16]
[--audiocodec stac9700|ad1980|stac9221|sb16]
[--clipboard-mode disabled|hosttoguest|guesttohost|
bidirectional]
[--draganddrop disabled|hosttoguest|guesttohost|
bidirectional]
[--vrde on|off]
[--vrdeextpack default|<name>]
[--vrdeproperty <name=[value]>]
[--vrdeport <hostport>]
[--vrdeaddress <hostip>]
[--vrdeauthtype null|external|guest]
[--vrdeauthlibrary default|<name>]
[--vrdemulticon on|off]
[--vrdereusecon on|off]
[--vrdevideochannel on|off]
[--vrdevideochannelquality <percent>]
[--usbohci on|off]
[--usbehci on|off]
[--usbxhci on|off]
[--usbrename <oldname> <newname>]
[--snapshotfolder default|<path>]
[--teleporter on|off]
[--teleporterport <port>]
[--teleporteraddress <address|empty>]
[--teleporterpassword <password>]
[--teleporterpasswordfile <file>|stdin]
[--tracing-enabled on|off]
[--tracing-config <config-string>]
[--tracing-allow-vm-access on|off]
[--usbcardreader on|off]
[--autostart-enabled on|off]
[--autostart-delay <seconds>]
[--recording on|off]
[--recordingscreens all|<screen ID> [<screen ID> ...]]
[--recordingfile <filename>]
[--recordingvideores <width> <height>]
[--recordingvideorate <rate>]
[--recordingvideofps <fps>]
[--recordingmaxtime <s>]
[--recordingmaxsize <MB>]
[--recordingopts <key=value> [,<key=value> ...]]
[--defaultfrontend default|<name>]
PS C:\Program Files\Oracle\VirtualBox>
Vagrantfile の設定例¶
仮想マシン名 |
sample-vm |
CPU |
2 |
メモリ |
4GB(4096MB) |
ネットワーク接続 |
ブリッジ |
MAC アドレス |
080027000001 |
ビデオカード |
vmsvga |
コンソール |
表示 |
ホスト名 |
node1 |
IP アドレス |
192.168.10.1 |
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
config.vm.hostname = "node1"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "sample-vm"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
end
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant ssh
[vagrant@node1 ~]$
[vagrant@node1 ~]$ hostname
node1
[vagrant@node1 ~]$
[vagrant@node1 ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86348sec preferred_lft 86348sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.1/24 brd 192.168.10.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
[vagrant@node1 ~]$
[vagrant@node1 ~]$ free -h
total used free shared buff/cache available
Mem: 3.7G 106M 3.5G 8.5M 137M 3.4G
Swap: 2.0G 0B 2.0G
[vagrant@node1 ~]$
[vagrant@node1 ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 62
model name : Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
stepping : 4
microcode : 0x19
cpu MHz : 3402.072
cache size : 12288 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase flush_l1d
bogomips : 6804.14
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 62
model name : Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
stepping : 4
microcode : 0x19
cpu MHz : 3402.072
cache size : 12288 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase flush_l1d
bogomips : 6804.14
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
[vagrant@node1 ~]$
[vagrant@node1 ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
プロビジョニング¶
プロビジョニングとは¶
Vagrantfile と Box ファイルで仮想マシンを作成した後にシェルスクリプトや Ansible などの構成管理ツールを使用し、アプリケーションのインストールや各種設定などの処理を行うことです。処理はvagrant up
コマンドの一部として動作します。
重要
プロビジョニングの実行はユーザー vagrant が sudo 付きで実行します。
実行タイミング¶
プロビジョニングは初回のvagrant up
コマンドの実行時に動作します。vagrant up
コマンドやvagrant reload
コマンドで強制的にプロビジョニングを実行する--provision
オプションがあります。明示的にプロビジョニングを実行しないようにする--no-provision
オプションがあります。常にプロビジョニングを実行する方法もあります。
基本動作¶
プロビジョニングを指定した Vagrantfile です。 Linux コマンドを実行するよう設定しました。網掛け部分がプロビジョニングに関係する部分です。
$script = <<-'SCRIPT'
echo hello, world
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
config.vm.hostname = "node1"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "sample-vm"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
end
仮想マシンが存在しない状態でvagrant up
→vagrant halt
→vagrant up
→vagrant halt
を実行した結果です。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
vagrant up
の実行結果からプロビジョニングの動作確認¶
初回¶
プロビジョニングが動作したことがわかります。
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
2 回目¶
プロビジョニング済みなので "Machine already provisioned." と表示されています。
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
--provision オプション¶
2 回目のvagrant up
コマンドの実行後に--provision
オプションを指定してvagrant up
コマンドを実行した結果です。プロビジョニングが動作しました。
PS C:\vagrant\my_centos> vagrant up --provision
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
プロビジョニングの常時実行¶
run: "always"
を指定すると常にプロビジョニングが動作します。
$script = <<-'SCRIPT'
echo hello, world
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
config.vm.hostname = "node1"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "sample-vm"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script, run: "always"
end
PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
PS C:\vagrant\my_centos>
シェル¶
インラインスクリプト¶
Vagrantfile 内にスクリプトを記述し、それを実行します。
スクリプトと実行部分です。
$script = <<-'SCRIPT'
echo hello, world
echo hello, Vagrant world !
SCRIPT
config.vm.provision "shell", inline: $script
$script 変数に設定した 1 つ以上のコマンドを順番に実行します。
Vagrantfile の全体です。
$script = <<-'SCRIPT'
echo hello, world
echo hello, Vagrant world !
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
config.vm.hostname = "node1"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "sample-vm"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
end
実行結果です。echo
コマンドの実行結果が表示されています。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
default: hello, Vagrant world !
PS C:\vagrant\my_centos>
複数のスクリプトの実行もできます。
$script = <<-'SCRIPT'
echo hello, world
SCRIPT
$script2 = <<-'SCRIPT'
echo hello, Vagrant world !
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001", ip: "192.168.10.1"
config.vm.hostname = "node1"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "sample-vm"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
config.vm.provision "shell", inline: $script2
end
実行結果です。config.vm.provision
が 2 回実行されています。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: sample-vm
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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 aborted. 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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, world
==> default: Running provisioner: shell...
default: Running: inline script
default: hello, Vagrant world !
PS C:\vagrant\my_centos>
nginx を使用した Web サーバーを構築する Vagrantfile です。
$script = <<-'SCRIPT'
yum -y install epel-release
yum -y install nginx
systemctl start nginx
systemctl enable nginx
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001"
config.vm.hostname = "web-sv"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "nginx"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
end
実行結果です。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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 reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. 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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: Loaded plugins: fastestmirror
default: Determining fastest mirrors
default: * base: ftp.iij.ad.jp
default: * extras: ftp.iij.ad.jp
default: * updates: ftp.iij.ad.jp
default: Resolving Dependencies
default: --> Running transaction check
default: ---> Package epel-release.noarch 0:7-11 will be installed
default: --> Finished Dependency Resolution
default:
default: Dependencies Resolved
default:
default: ================================================================================
default: Package Arch Version Repository Size
default: ================================================================================
default: Installing:
default: epel-release noarch 7-11 extras 15 k
default:
default: Transaction Summary
default: ================================================================================
default: Install 1 Package
default: Total download size: 15 k
default: Installed size: 24 k
default: Downloading packages:
default: Public key for epel-release-7-11.noarch.rpm is not installed
default: warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
default: Importing GPG key 0xF4A80EB5:
default: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
default: Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
default: Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
default: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
default: Running transaction check
default: Running transaction test
default: Transaction test succeeded
default: Running transaction
default: Installing : epel-release-7-11.noarch 1/1
default:
default: Verifying : epel-release-7-11.noarch 1/1
default:
default:
default: Installed:
default: epel-release.noarch 0:7-11
default: Complete!
default: Loaded plugins: fastestmirror
default: Loading mirror speeds from cached hostfile
default: * base: ftp.iij.ad.jp
default: * epel: nrt.edge.kernel.org
default: * extras: ftp.iij.ad.jp
default: * updates: ftp.iij.ad.jp
default: Resolving Dependencies
default: --> Running transaction check
default: ---> Package nginx.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: nginx-all-modules = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: nginx-filesystem = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: system-logos for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Running transaction check
default: ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
default: ---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
default: ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
default: ---> Package nginx-all-modules.noarch 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: nginx-mod-http-image-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-http-perl = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-mail = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-stream = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: ---> Package nginx-filesystem.noarch 1:1.16.1-1.el7 will be installed
default: --> Running transaction check
default: ---> Package nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
default: ---> Package nginx-mod-http-perl.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7 will be installed
default: ---> Package nginx-mod-mail.x86_64 1:1.16.1-1.el7 will be installed
default: ---> Package nginx-mod-stream.x86_64 1:1.16.1-1.el7 will be installed
default: --> Running transaction check
default: ---> Package gd.x86_64 0:2.0.35-26.el7 will be installed
default: --> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
default: --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
default: ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
default: ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
default: --> Running transaction check
default: ---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
default: --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
default: --> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
default: ---> Package libX11.x86_64 0:1.6.7-2.el7 will be installed
default: --> Processing Dependency: libX11-common >= 1.6.7-2.el7 for package: libX11-1.6.7-2.el7.x86_64
default: --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-2.el7.x86_64
default: ---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed
default: ---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be installed
default: ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
default: ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
default: ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
default: ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
default: ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
default: --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
default: --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
default: ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
default: ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
default: --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
default: --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
default: ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
default: ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
default: ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
default: ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
default: ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
default: ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
default: ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
default: ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
default: --> Running transaction check
default: ---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
default: --> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
default: ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
default: ---> Package libX11-common.noarch 0:1.6.7-2.el7 will be installed
default: ---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
default: --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
default: ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
default: ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
default: ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
default: --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
default: --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
default: ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
default: --> Running transaction check
default: ---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
default: ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
default: ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
default: --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
default: --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
default: ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
default: --> Running transaction check
default: ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
default: ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
default: --> Finished Dependency Resolution
default:
default: Dependencies Resolved
default:
default: ================================================================================
default: Package Arch Version Repository
default: Size
default: ================================================================================
default: Installing:
default: nginx x86_64 1:1.16.1-1.el7 epel 562 k
default: Installing for dependencies:
default: centos-indexhtml noarch 7-9.el7.centos base 92 k
default: centos-logos noarch 70.0.6-3.el7.centos base 21 M
default: dejavu-fonts-common noarch 2.33-6.el7 base 64 k
default: dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
default: fontconfig x86_64 2.13.0-4.3.el7 base 254 k
default: fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
default: gd x86_64 2.0.35-26.el7 base 146 k
default: gperftools-libs x86_64 2.6.1-1.el7 base 272 k
default: libX11 x86_64 1.6.7-2.el7 base 607 k
default: libX11-common noarch 1.6.7-2.el7 base 164 k
default: libXau x86_64 1.0.8-2.1.el7 base 29 k
default: libXpm x86_64 3.5.12-1.el7 base 55 k
default: libjpeg-turbo x86_64 1.2.90-8.el7 base 135 k
default: libxcb x86_64 1.13-1.el7 base 214 k
default: nginx-all-modules noarch 1:1.16.1-1.el7 epel 19 k
default: nginx-filesystem noarch 1:1.16.1-1.el7 epel 21 k
default: nginx-mod-http-image-filter x86_64 1:1.16.1-1.el7 epel 30 k
default: nginx-mod-http-perl x86_64 1:1.16.1-1.el7 epel 39 k
default: nginx-mod-http-xslt-filter x86_64 1:1.16.1-1.el7 epel 29 k
default: nginx-mod-mail x86_64 1:1.16.1-1.el7 epel 57 k
default: nginx-mod-stream x86_64 1:1.16.1-1.el7 epel 84 k
default: perl x86_64 4:5.16.3-294.el7_6 base 8.0 M
default: perl-Carp noarch 1.26-244.el7 base 19 k
default: perl-Encode x86_64 2.51-7.el7 base 1.5 M
default: perl-Exporter noarch 5.68-3.el7 base 28 k
default: perl-File-Path noarch 2.09-2.el7 base 26 k
default: perl-File-Temp noarch 0.23.01-3.el7 base 56 k
default: perl-Filter x86_64 1.49-3.el7 base 76 k
default: perl-Getopt-Long noarch 2.40-3.el7 base 56 k
default: perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
default: perl-PathTools x86_64 3.40-5.el7 base 82 k
default: perl-Pod-Escapes noarch 1:1.04-294.el7_6 base 51 k
default: perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
default: perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
default: perl-Pod-Usage noarch 1.63-3.el7 base 27 k
default: perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
default: perl-Socket x86_64 2.010-4.el7 base 49 k
default: perl-Storable x86_64 2.45-3.el7 base 77 k
default: perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
default: perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
default: perl-Time-Local noarch 1.2300-2.el7 base 24 k
default: perl-constant noarch 1.27-2.el7 base 19 k
default: perl-libs x86_64 4:5.16.3-294.el7_6 base 688 k
default: perl-macros x86_64 4:5.16.3-294.el7_6 base 44 k
default: perl-parent noarch 1:0.225-244.el7 base 12 k
default: perl-podlators noarch 2.5.1-3.el7 base 112 k
default: perl-threads x86_64 1.87-4.el7 base 49 k
default: perl-threads-shared x86_64 1.43-6.el7 base 39 k
default:
default: Transaction Summary
default: ================================================================================
default: Install 1 Package (+48 Dependent packages)
default: Total download size: 37 M
default: Installed size: 72 M
default: Downloading packages:
default: warning: /var/cache/yum/x86_64/7/epel/packages/nginx-1.16.1-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
default: Public key for nginx-1.16.1-1.el7.x86_64.rpm is not installed
default: --------------------------------------------------------------------------------
default: Total 13 MB/s | 37 MB 00:02
default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
default: Importing GPG key 0x352C64E5:
default: Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
default: Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
default: Package : epel-release-7-11.noarch (@extras)
default: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
default: Running transaction check
default: Running transaction test
default: Transaction test succeeded
default: Running transaction
default: Installing : fontpackages-filesystem-1.44-8.el7.noarch 1/49
default:
default: Installing : dejavu-fonts-common-2.33-6.el7.noarch 2/49
default:
default: Installing : dejavu-sans-fonts-2.33-6.el7.noarch 3/49
default:
default: Installing : fontconfig-2.13.0-4.3.el7.x86_64 4/49
default:
default: Installing : 1:perl-parent-0.225-244.el7.noarch 5/49
default:
default: Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 6/49
default:
default: Installing : perl-podlators-2.5.1-3.el7.noarch 7/49
default:
default: Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 8/49
default:
default: Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 9/49
default:
default: Installing : perl-Encode-2.51-7.el7.x86_64 10/49
default:
default: Installing : perl-Text-ParseWords-3.29-4.el7.noarch 11/49
default:
default: Installing : perl-Pod-Usage-1.63-3.el7.noarch 12/49
default:
default: Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64 13/49
default:
default: Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64 14/49
default:
default: Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 15/49
default:
default: Installing : perl-Exporter-5.68-3.el7.noarch 16/49
default:
default: Installing : perl-constant-1.27-2.el7.noarch 17/49
default:
default: Installing : perl-Time-Local-1.2300-2.el7.noarch 18/49
default:
default: Installing : perl-Socket-2.010-4.el7.x86_64 19/49
default:
default: Installing : perl-Carp-1.26-244.el7.noarch 20/49
default:
default: Installing : perl-Storable-2.45-3.el7.x86_64 21/49
default:
default: Installing : perl-PathTools-3.40-5.el7.x86_64 22/49
default:
default: Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 23/49
default:
default: Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 24/49
default:
default: Installing : perl-File-Temp-0.23.01-3.el7.noarch 25/49
default:
default: Installing : perl-File-Path-2.09-2.el7.noarch 26/49
default:
default: Installing : perl-threads-shared-1.43-6.el7.x86_64 27/49
default:
default: Installing : perl-threads-1.87-4.el7.x86_64 28/49
default:
default: Installing : perl-Filter-1.49-3.el7.x86_64 29/49
default:
default: Installing : perl-Getopt-Long-2.40-3.el7.noarch 30/49
default:
default: Installing : 4:perl-5.16.3-294.el7_6.x86_64 31/49
default:
default: Installing : gperftools-libs-2.6.1-1.el7.x86_64 32/49
default:
default: Installing : libXau-1.0.8-2.1.el7.x86_64 33/49
default:
default: Installing : libxcb-1.13-1.el7.x86_64 34/49
default:
default: Installing : centos-indexhtml-7-9.el7.centos.noarch 35/49
default:
default: Installing : libjpeg-turbo-1.2.90-8.el7.x86_64 36/49
default:
default: Installing : libX11-common-1.6.7-2.el7.noarch 37/49
default:
default: Installing : libX11-1.6.7-2.el7.x86_64 38/49
default:
default: Installing : libXpm-3.5.12-1.el7.x86_64 39/49
default:
default: Installing : gd-2.0.35-26.el7.x86_64 40/49
default:
default: Installing : centos-logos-70.0.6-3.el7.centos.noarch 41/49
default:
default: Installing : 1:nginx-filesystem-1.16.1-1.el7.noarch 42/49
default:
default: Installing : 1:nginx-mod-mail-1.16.1-1.el7.x86_64 43/49
default:
default: Installing : 1:nginx-mod-stream-1.16.1-1.el7.x86_64 44/49
default:
default: Installing : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64 45/49
default:
default: Installing : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64 46/49
default:
default: Installing : 1:nginx-1.16.1-1.el7.x86_64 47/49
default:
default: Installing : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64 48/49
default:
default: Installing : 1:nginx-all-modules-1.16.1-1.el7.noarch 49/49
default:
default: Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/49
default:
default: Verifying : fontconfig-2.13.0-4.3.el7.x86_64 2/49
default:
default: Verifying : 1:nginx-filesystem-1.16.1-1.el7.noarch 3/49
default:
default: Verifying : perl-threads-shared-1.43-6.el7.x86_64 4/49
default:
default: Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 5/49
default:
default: Verifying : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 6/49
default:
default: Verifying : perl-Exporter-5.68-3.el7.noarch 7/49
default:
default: Verifying : perl-constant-1.27-2.el7.noarch 8/49
default:
default: Verifying : perl-PathTools-3.40-5.el7.x86_64 9/49
default:
default: Verifying : 1:nginx-mod-mail-1.16.1-1.el7.x86_64 10/49
default:
default: Verifying : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64 11/49
default:
default: Verifying : dejavu-fonts-common-2.33-6.el7.noarch 12/49
default:
default: Verifying : fontpackages-filesystem-1.44-8.el7.noarch 13/49
default:
default: Verifying : centos-logos-70.0.6-3.el7.centos.noarch 14/49
default:
default: Verifying : 1:perl-parent-0.225-244.el7.noarch 15/49
default:
default: Verifying : perl-Pod-Usage-1.63-3.el7.noarch 16/49
default:
default: Verifying : 4:perl-libs-5.16.3-294.el7_6.x86_64 17/49
default:
default: Verifying : perl-File-Temp-0.23.01-3.el7.noarch 18/49
default:
default: Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 19/49
default:
default: Verifying : libX11-1.6.7-2.el7.x86_64 20/49
default:
default: Verifying : libX11-common-1.6.7-2.el7.noarch 21/49
default:
default: Verifying : libxcb-1.13-1.el7.x86_64 22/49
default:
default: Verifying : perl-Time-Local-1.2300-2.el7.noarch 23/49
default:
default: Verifying : 4:perl-macros-5.16.3-294.el7_6.x86_64 24/49
default:
default: Verifying : perl-Socket-2.010-4.el7.x86_64 25/49
default:
default: Verifying : libXpm-3.5.12-1.el7.x86_64 26/49
default:
default: Verifying : 1:nginx-mod-stream-1.16.1-1.el7.x86_64 27/49
default:
default: Verifying : perl-Carp-1.26-244.el7.noarch 28/49
default:
default: Verifying : perl-Storable-2.45-3.el7.x86_64 29/49
default:
default: Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 30/49
default:
default: Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 31/49
default:
default: Verifying : 1:nginx-1.16.1-1.el7.x86_64 32/49
default:
default: Verifying : libjpeg-turbo-1.2.90-8.el7.x86_64 33/49
default:
default: Verifying : 1:nginx-all-modules-1.16.1-1.el7.noarch 34/49
default:
default: Verifying : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64 35/49
default:
default: Verifying : centos-indexhtml-7-9.el7.centos.noarch 36/49
default:
default: Verifying : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64 37/49
default:
default: Verifying : perl-Encode-2.51-7.el7.x86_64 38/49
default:
default: Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 39/49
default:
default: Verifying : perl-podlators-2.5.1-3.el7.noarch 40/49
default:
default: Verifying : libXau-1.0.8-2.1.el7.x86_64 41/49
default:
default: Verifying : perl-File-Path-2.09-2.el7.noarch 42/49
default:
default: Verifying : perl-threads-1.87-4.el7.x86_64 43/49
default:
default: Verifying : gperftools-libs-2.6.1-1.el7.x86_64 44/49
default:
default: Verifying : perl-Filter-1.49-3.el7.x86_64 45/49
default:
default: Verifying : perl-Getopt-Long-2.40-3.el7.noarch 46/49
default:
default: Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 47/49
default:
default: Verifying : 4:perl-5.16.3-294.el7_6.x86_64 48/49
default:
default: Verifying : gd-2.0.35-26.el7.x86_64 49/49
default:
default:
default: Installed:
default: nginx.x86_64 1:1.16.1-1.el7
default:
default: Dependency Installed:
default: centos-indexhtml.noarch 0:7-9.el7.centos
default: centos-logos.noarch 0:70.0.6-3.el7.centos
default: dejavu-fonts-common.noarch 0:2.33-6.el7
default: dejavu-sans-fonts.noarch 0:2.33-6.el7
default: fontconfig.x86_64 0:2.13.0-4.3.el7
default: fontpackages-filesystem.noarch 0:1.44-8.el7
default: gd.x86_64 0:2.0.35-26.el7
default: gperftools-libs.x86_64 0:2.6.1-1.el7
default: libX11.x86_64 0:1.6.7-2.el7
default: libX11-common.noarch 0:1.6.7-2.el7
default: libXau.x86_64 0:1.0.8-2.1.el7
default: libXpm.x86_64 0:3.5.12-1.el7
default: libjpeg-turbo.x86_64 0:1.2.90-8.el7
default: libxcb.x86_64 0:1.13-1.el7
default: nginx-all-modules.noarch 1:1.16.1-1.el7
default: nginx-filesystem.noarch 1:1.16.1-1.el7
default: nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7
default: nginx-mod-http-perl.x86_64 1:1.16.1-1.el7
default: nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7
default: nginx-mod-mail.x86_64 1:1.16.1-1.el7
default: nginx-mod-stream.x86_64 1:1.16.1-1.el7
default: perl.x86_64 4:5.16.3-294.el7_6
default: perl-Carp.noarch 0:1.26-244.el7
default: perl-Encode.x86_64 0:2.51-7.el7
default: perl-Exporter.noarch 0:5.68-3.el7
default: perl-File-Path.noarch 0:2.09-2.el7
default: perl-File-Temp.noarch 0:0.23.01-3.el7
default: perl-Filter.x86_64 0:1.49-3.el7
default: perl-Getopt-Long.noarch 0:2.40-3.el7
default: perl-HTTP-Tiny.noarch 0:0.033-3.el7
default: perl-PathTools.x86_64 0:3.40-5.el7
default: perl-Pod-Escapes.noarch 1:1.04-294.el7_6
default: perl-Pod-Perldoc.noarch 0:3.20-4.el7
default: perl-Pod-Simple.noarch 1:3.28-4.el7
default: perl-Pod-Usage.noarch 0:1.63-3.el7
default: perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
default: perl-Socket.x86_64 0:2.010-4.el7
default: perl-Storable.x86_64 0:2.45-3.el7
default: perl-Text-ParseWords.noarch 0:3.29-4.el7
default: perl-Time-HiRes.x86_64 4:1.9725-3.el7
default: perl-Time-Local.noarch 0:1.2300-2.el7
default: perl-constant.noarch 0:1.27-2.el7
default: perl-libs.x86_64 4:5.16.3-294.el7_6
default: perl-macros.x86_64 4:5.16.3-294.el7_6
default: perl-parent.noarch 1:0.225-244.el7
default: perl-podlators.noarch 0:2.5.1-3.el7
default: perl-threads.x86_64 0:1.87-4.el7
default: perl-threads-shared.x86_64 0:1.43-6.el7
default: Complete!
default: Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
default: success
default: success
PS C:\vagrant\my_centos>
エクスターナルスクリプト¶
Vagrantfile とは別のファイルにシェルを記述し、そのファイルを実行します。
プロビジョニングで実行するシェルスクリプトです。
PS C:\vagrant\my_centos> cat .\provision\nginx.sh
yum -y install epel-release
yum -y install nginx
systemctl start nginx
systemctl enable nginx
systemctl start firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
PS C:\vagrant\my_centos>
Vagrantfile です。path:
で実行するシェルスクリプトファイルを指定します。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001"
config.vm.hostname = "web-sv"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "nginx"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", path: "./provision/nginx.sh"
end
実行結果です。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: C:/Users/user/AppData/Local/Temp/vagrant-shell20200208-16956-1flu3hj.sh
default: Loaded plugins: fastestmirror
default: Determining fastest mirrors
default: * base: ftp.iij.ad.jp
default: * extras: ftp.iij.ad.jp
default: * updates: ftp.iij.ad.jp
default: Resolving Dependencies
default: --> Running transaction check
default: ---> Package epel-release.noarch 0:7-11 will be installed
default: --> Finished Dependency Resolution
default:
default: Dependencies Resolved
default:
default: ================================================================================
default: Package Arch Version Repository Size
default: ================================================================================
default: Installing:
default: epel-release noarch 7-11 extras 15 k
default:
default: Transaction Summary
default: ================================================================================
default: Install 1 Package
default:
default: Total download size: 15 k
default: Installed size: 24 k
default: Downloading packages:
default: Public key for epel-release-7-11.noarch.rpm is not installed
default: warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
default: Importing GPG key 0xF4A80EB5:
default: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
default: Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
default: Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
default: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
default: Running transaction check
default: Running transaction test
default: Transaction test succeeded
default: Running transaction
default: Installing : epel-release-7-11.noarch 1/1
default:
default: Verifying : epel-release-7-11.noarch 1/1
default:
default:
default: Installed:
default: epel-release.noarch 0:7-11
default: Complete!
default: Loaded plugins: fastestmirror
default: Loading mirror speeds from cached hostfile
default: * base: ftp.iij.ad.jp
default: * epel: ftp.iij.ad.jp
default: * extras: ftp.iij.ad.jp
default: * updates: ftp.iij.ad.jp
default: Resolving Dependencies
default: --> Running transaction check
default: ---> Package nginx.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: nginx-all-modules = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: nginx-filesystem = 1:1.16.1-1.el7 for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: system-logos for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.16.1-1.el7.x86_64
default: --> Running transaction check
default: ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
default: ---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
default: ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
default: ---> Package nginx-all-modules.noarch 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: nginx-mod-http-image-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-http-perl = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-mail = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: --> Processing Dependency: nginx-mod-stream = 1:1.16.1-1.el7 for package: 1:nginx-all-modules-1.16.1-1.el7.noarch
default: ---> Package nginx-filesystem.noarch 1:1.16.1-1.el7 will be installed
default: --> Running transaction check
default: ---> Package nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64
default: ---> Package nginx-mod-http-perl.x86_64 1:1.16.1-1.el7 will be installed
default: --> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: --> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64
default: ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7 will be installed
default: ---> Package nginx-mod-mail.x86_64 1:1.16.1-1.el7 will be installed
default: ---> Package nginx-mod-stream.x86_64 1:1.16.1-1.el7 will be installed
default: --> Running transaction check
default: ---> Package gd.x86_64 0:2.0.35-26.el7 will be installed
default: --> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: --> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64
default: ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
default: --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
default: ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
default: ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
default: ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
default: --> Running transaction check
default: ---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
default: --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
default: --> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
default: ---> Package libX11.x86_64 0:1.6.7-2.el7 will be installed
default: --> Processing Dependency: libX11-common >= 1.6.7-2.el7 for package: libX11-1.6.7-2.el7.x86_64
default: --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-2.el7.x86_64
default: ---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed
default: ---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be installed
default: ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
default: ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
default: ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
default: ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
default: ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
default: --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
default: --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
default: ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
default: ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
default: --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
default: --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
default: ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
default: ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
default: ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
default: ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
default: ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
default: ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
default: ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
default: ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
default: --> Running transaction check
default: ---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
default: --> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
default: ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
default: ---> Package libX11-common.noarch 0:1.6.7-2.el7 will be installed
default: ---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
default: --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
default: ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
default: ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
default: ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
default: --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
default: --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
default: ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
default: --> Running transaction check
default: ---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
default: ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
default: ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
default: --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
default: --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
default: ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
default: --> Running transaction check
default: ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
default: ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
default: --> Finished Dependency Resolution
default:
default: Dependencies Resolved
default:
default: ================================================================================
default: Package Arch Version Repository
default: Size
default: ================================================================================
default: Installing:
default: nginx x86_64 1:1.16.1-1.el7 epel 562 k
default: Installing for dependencies:
default: centos-indexhtml noarch 7-9.el7.centos base 92 k
default: centos-logos noarch 70.0.6-3.el7.centos base 21 M
default: dejavu-fonts-common noarch 2.33-6.el7 base 64 k
default: dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
default: fontconfig x86_64 2.13.0-4.3.el7 base 254 k
default: fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
default: gd x86_64 2.0.35-26.el7 base 146 k
default: gperftools-libs x86_64 2.6.1-1.el7 base 272 k
default: libX11 x86_64 1.6.7-2.el7 base 607 k
default: libX11-common noarch 1.6.7-2.el7 base 164 k
default: libXau x86_64 1.0.8-2.1.el7 base 29 k
default: libXpm x86_64 3.5.12-1.el7 base 55 k
default: libjpeg-turbo x86_64 1.2.90-8.el7 base 135 k
default: libxcb x86_64 1.13-1.el7 base 214 k
default: nginx-all-modules noarch 1:1.16.1-1.el7 epel 19 k
default: nginx-filesystem noarch 1:1.16.1-1.el7 epel 21 k
default: nginx-mod-http-image-filter x86_64 1:1.16.1-1.el7 epel 30 k
default: nginx-mod-http-perl x86_64 1:1.16.1-1.el7 epel 39 k
default: nginx-mod-http-xslt-filter x86_64 1:1.16.1-1.el7 epel 29 k
default: nginx-mod-mail x86_64 1:1.16.1-1.el7 epel 57 k
default: nginx-mod-stream x86_64 1:1.16.1-1.el7 epel 84 k
default: perl x86_64 4:5.16.3-294.el7_6 base 8.0 M
default: perl-Carp noarch 1.26-244.el7 base 19 k
default: perl-Encode x86_64 2.51-7.el7 base 1.5 M
default: perl-Exporter noarch 5.68-3.el7 base 28 k
default: perl-File-Path noarch 2.09-2.el7 base 26 k
default: perl-File-Temp noarch 0.23.01-3.el7 base 56 k
default: perl-Filter x86_64 1.49-3.el7 base 76 k
default: perl-Getopt-Long noarch 2.40-3.el7 base 56 k
default: perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
default: perl-PathTools x86_64 3.40-5.el7 base 82 k
default: perl-Pod-Escapes noarch 1:1.04-294.el7_6 base 51 k
default: perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
default: perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
default: perl-Pod-Usage noarch 1.63-3.el7 base 27 k
default: perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
default: perl-Socket x86_64 2.010-4.el7 base 49 k
default: perl-Storable x86_64 2.45-3.el7 base 77 k
default: perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
default: perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
default: perl-Time-Local noarch 1.2300-2.el7 base 24 k
default: perl-constant noarch 1.27-2.el7 base 19 k
default: perl-libs x86_64 4:5.16.3-294.el7_6 base 688 k
default: perl-macros x86_64 4:5.16.3-294.el7_6 base 44 k
default: perl-parent noarch 1:0.225-244.el7 base 12 k
default: perl-podlators noarch 2.5.1-3.el7
default: base 112 k
default: perl-threads x86_64 1.87-4.el7 base 49 k
default: perl-threads-shared x86_64 1.43-6.el7 base 39 k
default:
default: Transaction Summary
default: ================================================================================
default: Install 1 Package (+48 Dependent packages)
default: Total download size: 37 M
default: Installed size: 72 M
default: Downloading packages:
default: Public key for nginx-all-modules-1.16.1-1.el7.noarch.rpm is not installed
default: warning: /var/cache/yum/x86_64/7/epel/packages/nginx-all-modules-1.16.1-1.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
default: --------------------------------------------------------------------------------
default: Total 9.7 MB/s | 37 MB 00:03
default: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
default: Importing GPG key 0x352C64E5:
default: Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
default: Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
default: Package : epel-release-7-11.noarch (@extras)
default: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
default: Running transaction check
default: Running transaction test
default: Transaction test succeeded
default: Running transaction
default: Installing : fontpackages-filesystem-1.44-8.el7.noarch 1/49
default:
default: Installing : dejavu-fonts-common-2.33-6.el7.noarch 2/49
default:
default: Installing : dejavu-sans-fonts-2.33-6.el7.noarch 3/49
default:
default: Installing : fontconfig-2.13.0-4.3.el7.x86_64 4/49
default:
default: Installing : 1:perl-parent-0.225-244.el7.noarch 5/49
default:
default: Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 6/49
default:
default: Installing : perl-podlators-2.5.1-3.el7.noarch 7/49
default:
default: Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 8/49
default:
default: Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 9/49
default:
default: Installing : perl-Encode-2.51-7.el7.x86_64 10/49
default:
default: Installing : perl-Text-ParseWords-3.29-4.el7.noarch 11/49
default:
default: Installing : perl-Pod-Usage-1.63-3.el7.noarch 12/49
default:
default: Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64 13/49
default:
default: Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64 14/49
default:
default: Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 15/49
default:
default: Installing : perl-Exporter-5.68-3.el7.noarch 16/49
default:
default: Installing : perl-constant-1.27-2.el7.noarch 17/49
default:
default: Installing : perl-Time-Local-1.2300-2.el7.noarch 18/49
default:
default: Installing : perl-Socket-2.010-4.el7.x86_64 19/49
default:
default: Installing : perl-Carp-1.26-244.el7.noarch 20/49
default:
default: Installing : perl-Storable-2.45-3.el7.x86_64 21/49
default:
default: Installing : perl-PathTools-3.40-5.el7.x86_64 22/49
default:
default: Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 23/49
default:
default: Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 24/49
default:
default: Installing : perl-File-Temp-0.23.01-3.el7.noarch 25/49
default:
default: Installing : perl-File-Path-2.09-2.el7.noarch 26/49
default:
default: Installing : perl-threads-shared-1.43-6.el7.x86_64 27/49
default:
default: Installing : perl-threads-1.87-4.el7.x86_64 28/49
default:
default: Installing : perl-Filter-1.49-3.el7.x86_64 29/49
default:
default: Installing : perl-Getopt-Long-2.40-3.el7.noarch 30/49
default:
default: Installing : 4:perl-5.16.3-294.el7_6.x86_64 31/49
default:
default: Installing : gperftools-libs-2.6.1-1.el7.x86_64 32/49
default:
default: Installing : libXau-1.0.8-2.1.el7.x86_64 33/49
default:
default: Installing : libxcb-1.13-1.el7.x86_64 34/49
default:
default: Installing : centos-indexhtml-7-9.el7.centos.noarch 35/49
default:
default: Installing : libjpeg-turbo-1.2.90-8.el7.x86_64 36/49
default:
default: Installing : libX11-common-1.6.7-2.el7.noarch 37/49
default:
default: Installing : libX11-1.6.7-2.el7.x86_64 38/49
default:
default: Installing : libXpm-3.5.12-1.el7.x86_64 39/49
default:
default: Installing : gd-2.0.35-26.el7.x86_64 40/49
default:
default: Installing : centos-logos-70.0.6-3.el7.centos.noarch 41/49
default:
default: Installing : 1:nginx-filesystem-1.16.1-1.el7.noarch 42/49
default:
default: Installing : 1:nginx-mod-mail-1.16.1-1.el7.x86_64 43/49
default:
default: Installing : 1:nginx-mod-stream-1.16.1-1.el7.x86_64 44/49
default:
default: Installing : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64 45/49
default:
default: Installing : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64 46/49
default:
default: Installing : 1:nginx-1.16.1-1.el7.x86_64 47/49
default:
default: Installing : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64 48/49
default:
default: Installing : 1:nginx-all-modules-1.16.1-1.el7.noarch 49/49
default:
default: Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/49
default:
default: Verifying : fontconfig-2.13.0-4.3.el7.x86_64 2/49
default:
default: Verifying : 1:nginx-filesystem-1.16.1-1.el7.noarch 3/49
default:
default: Verifying : perl-threads-shared-1.43-6.el7.x86_64 4/49
default:
default: Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 5/49
default:
default: Verifying : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 6/49
default:
default: Verifying : perl-Exporter-5.68-3.el7.noarch 7/49
default:
default: Verifying : perl-constant-1.27-2.el7.noarch 8/49
default:
default: Verifying : perl-PathTools-3.40-5.el7.x86_64 9/49
default:
default: Verifying : 1:nginx-mod-mail-1.16.1-1.el7.x86_64 10/49
default:
default: Verifying : 1:nginx-mod-http-perl-1.16.1-1.el7.x86_64 11/49
default:
default: Verifying : dejavu-fonts-common-2.33-6.el7.noarch 12/49
default:
default: Verifying : fontpackages-filesystem-1.44-8.el7.noarch 13/49
default:
default: Verifying : centos-logos-70.0.6-3.el7.centos.noarch 14/49
default:
default: Verifying : 1:perl-parent-0.225-244.el7.noarch 15/49
default:
default: Verifying : perl-Pod-Usage-1.63-3.el7.noarch 16/49
default:
default: Verifying : 4:perl-libs-5.16.3-294.el7_6.x86_64 17/49
default:
default: Verifying : perl-File-Temp-0.23.01-3.el7.noarch 18/49
default:
default: Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 19/49
default:
default: Verifying : libX11-1.6.7-2.el7.x86_64 20/49
default:
default: Verifying : libX11-common-1.6.7-2.el7.noarch 21/49
default:
default: Verifying : libxcb-1.13-1.el7.x86_64 22/49
default:
default: Verifying : perl-Time-Local-1.2300-2.el7.noarch 23/49
default:
default: Verifying : 4:perl-macros-5.16.3-294.el7_6.x86_64 24/49
default:
default: Verifying : perl-Socket-2.010-4.el7.x86_64 25/49
default:
default: Verifying : libXpm-3.5.12-1.el7.x86_64 26/49
default:
default: Verifying : 1:nginx-mod-stream-1.16.1-1.el7.x86_64 27/49
default:
default: Verifying : perl-Carp-1.26-244.el7.noarch 28/49
default:
default: Verifying : perl-Storable-2.45-3.el7.x86_64 29/49
default:
default: Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 30/49
default:
default: Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 31/49
default:
default: Verifying : 1:nginx-1.16.1-1.el7.x86_64 32/49
default:
default: Verifying : libjpeg-turbo-1.2.90-8.el7.x86_64 33/49
default:
default: Verifying : 1:nginx-all-modules-1.16.1-1.el7.noarch 34/49
default:
default: Verifying : 1:nginx-mod-http-xslt-filter-1.16.1-1.el7.x86_64 35/49
default:
default: Verifying : centos-indexhtml-7-9.el7.centos.noarch 36/49
default:
default: Verifying : 1:nginx-mod-http-image-filter-1.16.1-1.el7.x86_64 37/49
default:
default: Verifying : perl-Encode-2.51-7.el7.x86_64 38/49
default:
default: Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 39/49
default:
default: Verifying : perl-podlators-2.5.1-3.el7.noarch 40/49
default:
default: Verifying : libXau-1.0.8-2.1.el7.x86_64 41/49
default:
default: Verifying : perl-File-Path-2.09-2.el7.noarch 42/49
default:
default: Verifying : perl-threads-1.87-4.el7.x86_64 43/49
default:
default: Verifying : gperftools-libs-2.6.1-1.el7.x86_64 44/49
default:
default: Verifying : perl-Filter-1.49-3.el7.x86_64 45/49
default:
default: Verifying : perl-Getopt-Long-2.40-3.el7.noarch 46/49
default:
default: Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 47/49
default:
default: Verifying : 4:perl-5.16.3-294.el7_6.x86_64 48/49
default:
default: Verifying : gd-2.0.35-26.el7.x86_64 49/49
default:
default:
default: Installed:
default: nginx.x86_64 1:1.16.1-1.el7
default:
default: Dependency Installed:
default: centos-indexhtml.noarch 0:7-9.el7.centos
default: centos-logos.noarch 0:70.0.6-3.el7.centos
default: dejavu-fonts-common.noarch 0:2.33-6.el7
default: dejavu-sans-fonts.noarch 0:2.33-6.el7
default: fontconfig.x86_64 0:2.13.0-4.3.el7
default: fontpackages-filesystem.noarch 0:1.44-8.el7
default: gd.x86_64 0:2.0.35-26.el7
default: gperftools-libs.x86_64 0:2.6.1-1.el7
default: libX11.x86_64 0:1.6.7-2.el7
default: libX11-common.noarch 0:1.6.7-2.el7
default: libXau.x86_64 0:1.0.8-2.1.el7
default: libXpm.x86_64 0:3.5.12-1.el7
default: libjpeg-turbo.x86_64 0:1.2.90-8.el7
default: libxcb.x86_64 0:1.13-1.el7
default: nginx-all-modules.noarch 1:1.16.1-1.el7
default: nginx-filesystem.noarch 1:1.16.1-1.el7
default: nginx-mod-http-image-filter.x86_64 1:1.16.1-1.el7
default: nginx-mod-http-perl.x86_64 1:1.16.1-1.el7
default: nginx-mod-http-xslt-filter.x86_64 1:1.16.1-1.el7
default: nginx-mod-mail.x86_64 1:1.16.1-1.el7
default: nginx-mod-stream.x86_64 1:1.16.1-1.el7
default: perl.x86_64 4:5.16.3-294.el7_6
default: perl-Carp.noarch 0:1.26-244.el7
default: perl-Encode.x86_64 0:2.51-7.el7
default: perl-Exporter.noarch 0:5.68-3.el7
default: perl-File-Path.noarch 0:2.09-2.el7
default: perl-File-Temp.noarch 0:0.23.01-3.el7
default: perl-Filter.x86_64 0:1.49-3.el7
default: perl-Getopt-Long.noarch 0:2.40-3.el7
default: perl-HTTP-Tiny.noarch 0:0.033-3.el7
default: perl-PathTools.x86_64 0:3.40-5.el7
default: perl-Pod-Escapes.noarch 1:1.04-294.el7_6
default: perl-Pod-Perldoc.noarch 0:3.20-4.el7
default: perl-Pod-Simple.noarch 1:3.28-4.el7
default: perl-Pod-Usage.noarch 0:1.63-3.el7
default: perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
default: perl-Socket.x86_64 0:2.010-4.el7
default: perl-Storable.x86_64 0:2.45-3.el7
default: perl-Text-ParseWords.noarch 0:3.29-4.el7
default: perl-Time-HiRes.x86_64 4:1.9725-3.el7
default: perl-Time-Local.noarch 0:1.2300-2.el7
default: perl-constant.noarch 0:1.27-2.el7
default: perl-libs.x86_64 4:5.16.3-294.el7_6
default: perl-macros.x86_64 4:5.16.3-294.el7_6
default: perl-parent.noarch 1:0.225-244.el7
default: perl-podlators.noarch 0:2.5.1-3.el7
default: perl-threads.x86_64 0:1.87-4.el7
default: perl-threads-shared.x86_64 0:1.43-6.el7
default:
default: Complete!
default: Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
default: success
default: success
PS C:\vagrant\my_centos>
Ansible¶
Ansible を使用してプロビジョニングします。エクスターナルスクリプトと同様に Vagrantfile とは別にプレイブックファイルを用意します。
注釈
プロビジョニング対象の仮想マシンに Ansible がインストールされていないときは自動でインストールされます。
プロビジョニングで実行するプレイブックファイルです。
PS C:\vagrant\my_centos> cat .\provision\nginx.yml
---
- hosts: all
become: yes
tasks:
- name: install Nginx
yum:
name: nginx
state: latest
notify:
- nginx restart
- name: firewalld start
systemd:
name: firewalld
enabled: yes
state: started
- name: firewalld enable http
firewalld:
service: http
immediate: yes
permanent: yes
state: enabled
handlers:
- name: nginx service restarted
systemd:
name: nginx
enabled: yes
state: restarted
listen:
- nginx restart
PS C:\vagrant\my_centos>
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "./provision/nginx.yml"
end
Vagrantfile の全体です。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "080027000001"
config.vm.hostname = "web-sv"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "nginx"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "./provision/nginx.yml"
end
end
実行結果です。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: nginx
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: ansible_local...
default: Installing Ansible...
Vagrant has automatically selected the compatibility mode '2.0'
according to the Ansible version installed (2.9.3).
Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode
default: Running ansible-playbook...
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [default]
TASK [install Nginx] ***********************************************************
changed: [default]
TASK [firewalld start] *********************************************************
changed: [default]
TASK [firewalld enable http] ***************************************************
changed: [default]
RUNNING HANDLER [nginx service restarted] **************************************
changed: [default]
PLAY RECAP *********************************************************************
default : ok=5 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
PS C:\vagrant\my_centos>
BOX ファイルの作成¶
作成した仮想マシンを元に Box ファイルを作成します。作成した Box ファイルをvagrant box add
コマンドで登録して使用できます。作成した Box ファイルを配布することで、同じ環境を提供できます。
Box ファイルの元になる仮想マシンの作成¶
Box ファイルの元になる仮想マシンを作成します。今回は次の Vagrantfile で作成した仮想マシンを使用します。
$script = <<-'SCRIPT'
yum -y update
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "public_network", mac: "00006C000001"
config.vm.hostname = "centos7sv"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "centos7.7"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
end
実行ログです。実行環境に付録で記載した「プラグインを使用した VB Guest Additions のインストール」を実行済みなので、 VB Guest Additions もインストールされます。プロビジョニングですべてのインストール済みパッケージをアップデートしたり、動作確認などもしているのでかなり長い実行ログです。
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: centos7.7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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] No Virtualbox Guest Additions installation found.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* extras: mirrors.cat.net
* updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package centos-release.x86_64 0:7-6.1810.2.el7.centos will be updated
---> Package centos-release.x86_64 0:7-7.1908.0.el7.centos will be an update
--> Finished Dependency Resolution
***省略***
Uncompressing VirtualBox 6.1.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel
3.10.0-957.12.2.el7.x86_64.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: Loaded plugins: fastestmirror
default: Loading mirror speeds from cached hostfile
default: * base: mirrors.cat.net
default: * extras: mirrors.cat.net
default: * updates: mirrors.cat.net
default: Resolving Dependencies
default: --> Running transaction check
default: ---> Package GeoIP.x86_64 0:1.5.0-13.el7 will be updated
***省略***
default: yum.noarch 0:3.4.3-163.el7.centos
default: yum-plugin-fastestmirror.noarch 0:1.1.31-52.el7
default: yum-utils.noarch 0:1.1.31-52.el7
default: Complete!
PS C:\vagrant\my_centos> vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Machine booted and ready!
[default] GuestAdditions 6.1.2 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\my_centos> vagrant ssh
[vagrant@centos7sv ~]$ hostname
centos7sv
[vagrant@centos7sv ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86366sec preferred_lft 86366sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:00:6c:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.37/24 brd 192.168.1.255 scope global noprefixroute dynamic eth1
valid_lft 14366sec preferred_lft 14366sec
inet6 fe80::200:6cff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
[vagrant@centos7sv ~]$ free -h
total used free shared buff/cache available
Mem: 3.7G 134M 3.4G 8.5M 150M 3.4G
Swap: 2.0G 0B 2.0G
[vagrant@centos7sv ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 62
model name : Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
stepping : 4
microcode : 0x19
cpu MHz : 3402.072
cache size : 12288 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht
syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 s
se4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase flush_l1d
bogomips : 6804.14
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 62
model name : Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
stepping : 4
microcode : 0x19
cpu MHz : 3402.072
cache size : 12288 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht
syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 s
se4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase flush_l1d
bogomips : 6804.14
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
[vagrant@centos7sv ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\my_centos> ssh vagrant@192.168.1.37 -i C:\vagrant\my_centos\.vagrant\machines\default\virtualbox\private_key
The authenticity of host '192.168.1.37 (192.168.1.37)' can't be established.
ECDSA key fingerprint is SHA256:OGvzBcMkU+p1UVib5V1u6adTUK1VQC1L8Wb2/xogZEY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.37' (ECDSA) to the list of known hosts.
Last login: Tue Feb 11 03:21:47 2020 from 10.0.2.2
[vagrant@centos7sv ~]$ logout
Connection to 192.168.1.37 closed.
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
Box ファイルの作成¶
「Box ファイルの元になる仮想マシンの作成」で作成した仮想マシンを元にvagrant package
コマンドで Box ファイルを作成します。
主なオプション¶
- --output
Box ファイル名を指定します。
このオプションを省略したときの Box ファイル名は "package.box" です。
- --vagrantfile
指定した Vagrantfile を取り込んだ Box ファイルを作成します。
使用例¶
オプションなし¶
PS C:\vagrant\my_centos> vagrant package
==> default: Clearing any previously set forwarded ports...
==> default: Exporting VM...
==> default: Compressing package to: C:/vagrant/my_centos/package.box
PS C:\vagrant\my_centos> ls
ディレクトリ: C:\vagrant\my_centos
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/02/11 12:09 .vagrant
-a---- 2020/02/11 13:19 1071263024 package.box
-a---- 2020/02/11 11:59 515 Vagrantfile
PS C:\vagrant\my_centos>
--output オプション¶
PS C:\vagrant\my_centos> vagrant package --output mycentos7.box
==> default: Exporting VM...
==> default: Compressing package to: C:/vagrant/my_centos/mycentos7.box
PS C:\vagrant\my_centos> ls
ディレクトリ: C:\vagrant\my_centos
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/02/11 12:09 .vagrant
-a---- 2020/02/11 13:22 1071262843 mycentos7.box
-a---- 2020/02/11 11:59 515 Vagrantfile
PS C:\vagrant\my_centos>
--output オプションと --vagrantfile オプション¶
PS C:\vagrant\my_centos> vagrant package --output mycentos7-custom.box --vagrantfile .\Vagrantfile
==> default: Exporting VM...
==> default: Compressing package to: C:/vagrant/my_centos/mycentos7-custom.box
==> default: Packaging additional file: .\Vagrantfile
PS C:\vagrant\my_centos> ls
ディレクトリ: C:\vagrant\my_centos
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/02/11 12:09 .vagrant
-a---- 2020/02/11 13:25 1071263119 mycentos7-custom.box
-a---- 2020/02/11 11:59 515 Vagrantfile
PS C:\vagrant\my_centos>
作成した Box ファイルの使用¶
作成した Box ファイルを実際に使用します。
Box ファイルの登録¶
Box ファイルを使用するためvagrant box add
コマンドで登録します。 Vagrant Cloud から Box ファイルを取得する場合とは違い、作成した Box ファイルの指定が必要です。今回は mycentos と mycentos-custom という名称で作成した Box ファイルを登録します。
PS C:\vagrant\my_centos> ls
ディレクトリ: C:\vagrant\my_centos
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/02/11 12:09 .vagrant
-a---- 2020/02/11 13:25 1071263119 mycentos7-custom.box
-a---- 2020/02/11 13:22 1071262843 mycentos7.box
-a---- 2020/02/11 13:19 1071263024 package.box
-a---- 2020/02/11 11:59 515 Vagrantfile
PS C:\vagrant\my_centos> vagrant box list
centos/7 (virtualbox, 1905.1)
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant box add mycentos package.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'mycentos' (v0) for provider:
box: Unpacking necessary files from: file://C:/vagrant/my_centos/package.box
box:
==> box: Successfully added box 'mycentos' (v0) for 'virtualbox'!
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant box add mycentos-custom .\mycentos7-custom.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'mycentos-custom' (v0) for provider:
box: Unpacking necessary files from: file://C:/vagrant/my_centos/mycentos7-custom.box
box:
==> box: Successfully added box 'mycentos-custom' (v0) for 'virtualbox'!
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant box list
centos/7 (virtualbox, 1905.1)
mycentos (virtualbox, 0)
mycentos-custom (virtualbox, 0)
PS C:\vagrant\my_centos>
Box ファイルを元に仮想マシンを作成¶
Box ファイルを作成したフォルダーとは別のフォルダーで仮想マシンを作成し、内容を確認します。
Vagrantfile を取り込まないで Box ファイルを作成した場合¶
Ovacle VM VirtualBox マネージャーで仮想マシン自体のサマリーを確認すると、登録されている仮想マシン名がデフォルトになっていたり、ネットワークアダプターが 1 つだけなど、元の仮想マシンの仕様と多少の差異が発生しています。
作成されたばかりの Vagrantfile は
config.vm.box
だけが定義されています。vagrant up
コマンドのログを確認すると VB Guest Additions が導入されていることがわかります。vagrant ssh
コマンドで接続して確認すると、元の仮想マシンと同じホスト名になっており、各パッケージもアップデート済みです。

PS C:\vagrant\test> ls
PS C:\vagrant\test> vagrant init mycentos
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.
PS C:\vagrant\test> cat .\Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "mycentos"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
PS C:\vagrant\test> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'mycentos'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: test_default_1581398944542_1280
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (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: Machine booted and ready!
[default] GuestAdditions 6.1.2 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => C:/vagrant/test
PS C:\vagrant\test> vagrant ssh
Last login: Tue Feb 11 03:24:13 2020 from 192.168.1.50
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ sudo yum -y update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* extras: mirrors.cat.net
* updates: mirrors.cat.net
No packages marked for update
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86267sec preferred_lft 86267sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\test> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\test>
Vagrantfile を取り込んで Box ファイルを作成した場合¶
Ovacle VM VirtualBox マネージャーで仮想マシン自体のサマリーを確認すると、仮想マシン名やネットワークアダプターの数や設定などが元になった仮想マシンのものと同じ設定になっています。
作成されたばかりの Vagrantfile は
config.vm.box
だけが定義されています。vagrant up
コマンドのログを確認すると VB Guest Additions が導入されていることがわかります。vagrant ssh
コマンドで接続して確認すると、元の仮想マシンと同じホスト名になっており、各パッケージもアップデート済み、MAC アドレスも同じになっています。

PS C:\vagrant\test> ls
PS C:\vagrant\test> vagrant init mycentos-custom
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.
PS C:\vagrant\test> cat .\Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "mycentos-custom"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
PS C:\vagrant\test> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'mycentos-custom'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: centos7.7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Machine booted and ready!
[default] GuestAdditions 6.1.2 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/vagrant/test
==> default: Running provisioner: shell...
default: Running: inline script
default: Loaded plugins: fastestmirror
default: Loading mirror speeds from cached hostfile
default: * base: mirrors.cat.net
default: * extras: mirrors.cat.net
default: * updates: mirrors.cat.net
default: No packages marked for update
PS C:\vagrant\test> vagrant ssh
Last login: Tue Feb 11 03:24:13 2020 from 192.168.1.50
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ sudo yum -y update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* extras: mirrors.cat.net
* updates: mirrors.cat.net
No packages marked for update
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86324sec preferred_lft 86324sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:00:6c:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.37/24 brd 192.168.1.255 scope global noprefixroute dynamic eth1
valid_lft 14324sec preferred_lft 14324sec
inet6 fe80::200:6cff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
[vagrant@centos7sv ~]$
[vagrant@centos7sv ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\test>
PS C:\vagrant\test> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\test>
複数の仮想マシンの操作¶
Vagrantfile に複数の仮想マシンを定義できます。これにより、一度に複数の仮想マシンを作成するなどの操作が可能になります。仮想マシンごとの操作も可能です。
仮想マシンの定義¶
config.vm.define
を使用して、仮想マシンごとに定義します。config.vm.define
の後に定義した名前( websv, dbsv )が Vagrant 内の仮想マシンの識別名です。
config.vm.define :websv do |web|
仮想マシンごとの定義
end
Web サーバーとデータベースサーバーの 2 台の仮想マシンを定義した Vagrantfile です。
$scriptweb = <<-'SCRIPT'
echo hello, Web world
SCRIPT
$scriptdb = <<-'SCRIPT'
echo hello, db world
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define :websv do |web|
web.vm.box = "centos/7"
web.vm.network "public_network", mac: "080027000001"
web.vm.hostname = "websv"
web.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "webserver"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
web.vm.provision "shell", inline: $scriptweb
end
config.vm.define :dbsv do |db|
db.vm.box = "centos/7"
db.vm.network "public_network", mac: "080027000002"
db.vm.hostname = "dbsv"
db.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "dbserver"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
db.vm.provision "shell", inline: $scriptdb
end
end
実行結果です。ログの各行の先頭に Vagrant 内の仮想マシンの識別名が表示されます。一部のコマンドを除いてvagrant up
やvagrant halt
など仮想マシンに対するコマンドはすべての仮想マシンに適用されます。
PS C:\vagrant\multi> vagrant up
Bringing machine 'websv' up with 'virtualbox' provider...
Bringing machine 'dbsv' up with 'virtualbox' provider...
==> websv: Importing base box 'centos/7'...
==> websv: Matching MAC address for NAT networking...
==> websv: Checking if box 'centos/7' version '1905.1' is up to date...
==> websv: Setting the name of the VM: webserver
==> websv: Clearing any previously set network interfaces...
==> websv: Preparing network interfaces based on configuration...
websv: Adapter 1: nat
websv: Adapter 2: bridged
==> websv: Forwarding ports...
websv: 22 (guest) => 2222 (host) (adapter 1)
==> websv: Running 'pre-boot' VM customizations...
==> websv: Booting VM...
==> websv: Waiting for machine to boot. This may take a few minutes...
websv: SSH address: 127.0.0.1:2222
websv: SSH username: vagrant
websv: SSH auth method: private key
websv:
websv: Vagrant insecure key detected. Vagrant will automatically replace
websv: this with a newly generated keypair for better security.
websv:
websv: Inserting generated public key within guest...
websv: Removing insecure key from the guest if it's present...
websv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> websv: Machine booted and ready!
==> websv: Checking for guest additions in VM...
websv: No guest additions were detected on the base box for this VM! Guest
websv: additions are required for forwarded ports, shared folders, host only
websv: networking, and more. If SSH fails on this machine, please install
websv: the guest additions and repackage the box to continue.
websv:
websv: This is not an error message; everything may continue to work properly,
websv: in which case you may ignore this message.
==> websv: Setting hostname...
==> websv: Configuring and enabling network interfaces...
==> websv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Web world
==> dbsv: Importing base box 'centos/7'...
==> dbsv: Matching MAC address for NAT networking...
==> dbsv: Checking if box 'centos/7' version '1905.1' is up to date...
==> dbsv: Setting the name of the VM: dbserver
==> dbsv: Fixed port collision for 22 => 2222. Now on port 2200.
==> dbsv: Clearing any previously set network interfaces...
==> dbsv: Preparing network interfaces based on configuration...
dbsv: Adapter 1: nat
dbsv: Adapter 2: bridged
==> dbsv: Forwarding ports...
dbsv: 22 (guest) => 2200 (host) (adapter 1)
==> dbsv: Running 'pre-boot' VM customizations...
==> dbsv: Booting VM...
==> dbsv: Waiting for machine to boot. This may take a few minutes...
dbsv: SSH address: 127.0.0.1:2200
dbsv: SSH username: vagrant
dbsv: SSH auth method: private key
dbsv:
dbsv: Vagrant insecure key detected. Vagrant will automatically replace
dbsv: this with a newly generated keypair for better security.
dbsv:
dbsv: Inserting generated public key within guest...
dbsv: Removing insecure key from the guest if it's present...
dbsv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> dbsv: Machine booted and ready!
==> dbsv: Checking for guest additions in VM...
dbsv: No guest additions were detected on the base box for this VM! Guest
dbsv: additions are required for forwarded ports, shared folders, host only
dbsv: networking, and more. If SSH fails on this machine, please install
dbsv: the guest additions and repackage the box to continue.
dbsv:
dbsv: This is not an error message; everything may continue to work properly,
dbsv: in which case you may ignore this message.
==> dbsv: Setting hostname...
==> dbsv: Configuring and enabling network interfaces...
==> dbsv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, db world
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant halt
==> dbsv: Attempting graceful shutdown of VM...
==> websv: Attempting graceful shutdown of VM...
PS C:\vagrant\multi>
共通した定義の取り扱い¶
「仮想マシンの定義」で使用した Vagrantfile です。
$scriptweb = <<-'SCRIPT'
echo hello, Web world
SCRIPT
$scriptdb = <<-'SCRIPT'
echo hello, db world
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define :websv do |web|
web.vm.box = "centos/7"
web.vm.network "public_network", mac: "080027000001"
web.vm.hostname = "websv"
web.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "webserver"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
web.vm.provision "shell", inline: $scriptweb
end
config.vm.define :dbsv do |db|
db.vm.box = "centos/7"
db.vm.network "public_network", mac: "080027000002"
db.vm.hostname = "dbsv"
db.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.name = "dbserver"
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
db.vm.provision "shell", inline: $scriptdb
end
end
いくつかの項目は同じ値を設定しています。このような共通項目をまとめて定義し、仮想マシンごとの定義はconfig.vm.define
で定義します。
Vagrant.configure("2") do |config|
共通の定義
config.vm.define :websv do |web|
仮想マシン固有の定義
end
end
共通の定義部分をまとめて定義した Vagrantfile です。追加として今回は共通部分にもconfig.vm.provision
を入れています。
$script = <<-'SCRIPT'
echo hello, Vagrant world
SCRIPT
$scriptweb = <<-'SCRIPT'
echo hello, Web world
SCRIPT
$scriptdb = <<-'SCRIPT'
echo hello, db world
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "4096"
vb.cpus = 2
vb.customize [
"modifyvm", :id,
"--ioapic", "on",
"--graphicscontroller", "vmsvga"
]
end
config.vm.provision "shell", inline: $script
config.vm.define :websv do |web|
web.vm.network "public_network", mac: "080027000001"
web.vm.hostname = "websv"
web.vm.provider "virtualbox" do |vb|
vb.name = "webserver"
end
web.vm.provision "shell", inline: $scriptweb
end
config.vm.define :dbsv do |db|
db.vm.network "public_network", mac: "080027000002"
db.vm.hostname = "dbsv"
db.vm.provider "virtualbox" do |vb|
vb.name = "dbserver"
end
db.vm.provision "shell", inline: $scriptdb
end
end
実行結果です。共通部分、固有部分を組み合わせて処理していることがわかります。
PS C:\vagrant\multi> vagrant up
Bringing machine 'websv' up with 'virtualbox' provider...
Bringing machine 'dbsv' up with 'virtualbox' provider...
==> websv: Importing base box 'centos/7'...
==> websv: Matching MAC address for NAT networking...
==> websv: Checking if box 'centos/7' version '1905.1' is up to date...
==> websv: Setting the name of the VM: webserver
==> websv: Clearing any previously set network interfaces...
==> websv: Preparing network interfaces based on configuration...
websv: Adapter 1: nat
websv: Adapter 2: bridged
==> websv: Forwarding ports...
websv: 22 (guest) => 2222 (host) (adapter 1)
==> websv: Running 'pre-boot' VM customizations...
==> websv: Booting VM...
==> websv: Waiting for machine to boot. This may take a few minutes...
websv: SSH address: 127.0.0.1:2222
websv: SSH username: vagrant
websv: SSH auth method: private key
websv:
websv: Vagrant insecure key detected. Vagrant will automatically replace
websv: this with a newly generated keypair for better security.
websv:
websv: Inserting generated public key within guest...
websv: Removing insecure key from the guest if it's present...
websv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> websv: Machine booted and ready!
==> websv: Checking for guest additions in VM...
websv: No guest additions were detected on the base box for this VM! Guest
websv: additions are required for forwarded ports, shared folders, host only
websv: networking, and more. If SSH fails on this machine, please install
websv: the guest additions and repackage the box to continue.
websv:
websv: This is not an error message; everything may continue to work properly,
websv: in which case you may ignore this message.
==> websv: Setting hostname...
==> websv: Configuring and enabling network interfaces...
==> websv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Vagrant world
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Web world
==> dbsv: Importing base box 'centos/7'...
==> dbsv: Matching MAC address for NAT networking...
==> dbsv: Checking if box 'centos/7' version '1905.1' is up to date...
==> dbsv: Setting the name of the VM: dbserver
==> dbsv: Fixed port collision for 22 => 2222. Now on port 2200.
==> dbsv: Clearing any previously set network interfaces...
==> dbsv: Preparing network interfaces based on configuration...
dbsv: Adapter 1: nat
dbsv: Adapter 2: bridged
==> dbsv: Forwarding ports...
dbsv: 22 (guest) => 2200 (host) (adapter 1)
==> dbsv: Running 'pre-boot' VM customizations...
==> dbsv: Booting VM...
==> dbsv: Waiting for machine to boot. This may take a few minutes...
dbsv: SSH address: 127.0.0.1:2200
dbsv: SSH username: vagrant
dbsv: SSH auth method: private key
dbsv:
dbsv: Vagrant insecure key detected. Vagrant will automatically replace
dbsv: this with a newly generated keypair for better security.
dbsv:
dbsv: Inserting generated public key within guest...
dbsv: Removing insecure key from the guest if it's present...
dbsv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> dbsv: Machine booted and ready!
==> dbsv: Checking for guest additions in VM...
dbsv: No guest additions were detected on the base box for this VM! Guest
dbsv: additions are required for forwarded ports, shared folders, host only
dbsv: networking, and more. If SSH fails on this machine, please install
dbsv: the guest additions and repackage the box to continue.
dbsv:
dbsv: This is not an error message; everything may continue to work properly,
dbsv: in which case you may ignore this message.
==> dbsv: Setting hostname...
==> dbsv: Configuring and enabling network interfaces...
==> dbsv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, Vagrant world
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, db world
PS C:\vagrant\multi>
プロビジョニングの部分です。どちらの仮想マシンも共通部分のプロビジョニングの実行後、仮想マシン固有のプロビジョニングを実行しています。
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Vagrant world
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Web world
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, Vagrant world
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, db world
Vagrant コマンド¶
vagrant up
やvagrant halt
などの Vagrant コマンドは、定義した複数の仮想マシンすべてに対し適用されます。任意の仮想マシンに適用するには Vagrant コマンドに続けて Vagrant 内の仮想マシン名を指定します。
注釈
複数の仮想マシンを定義した環境のvagrant ssh
コマンドは仮想マシンの指定が必須です。
仮想マシン名を指定した実行結果です。
PS C:\vagrant\multi> vagrant up dbsv
Bringing machine 'dbsv' up with 'virtualbox' provider...
==> dbsv: Importing base box 'centos/7'...
==> dbsv: Matching MAC address for NAT networking...
==> dbsv: Checking if box 'centos/7' version '1905.1' is up to date...
==> dbsv: Setting the name of the VM: dbserver
==> dbsv: Clearing any previously set network interfaces...
==> dbsv: Preparing network interfaces based on configuration...
dbsv: Adapter 1: nat
dbsv: Adapter 2: bridged
==> dbsv: Forwarding ports...
dbsv: 22 (guest) => 2222 (host) (adapter 1)
==> dbsv: Running 'pre-boot' VM customizations...
==> dbsv: Booting VM...
==> dbsv: Waiting for machine to boot. This may take a few minutes...
dbsv: SSH address: 127.0.0.1:2222
dbsv: SSH username: vagrant
dbsv: SSH auth method: private key
dbsv:
dbsv: Vagrant insecure key detected. Vagrant will automatically replace
dbsv: this with a newly generated keypair for better security.
dbsv:
dbsv: Inserting generated public key within guest...
dbsv: Removing insecure key from the guest if it's present...
dbsv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> dbsv: Machine booted and ready!
==> dbsv: Checking for guest additions in VM...
dbsv: No guest additions were detected on the base box for this VM! Guest
dbsv: additions are required for forwarded ports, shared folders, host only
dbsv: networking, and more. If SSH fails on this machine, please install
dbsv: the guest additions and repackage the box to continue.
dbsv:
dbsv: This is not an error message; everything may continue to work properly,
dbsv: in which case you may ignore this message.
==> dbsv: Setting hostname...
==> dbsv: Configuring and enabling network interfaces...
==> dbsv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, Vagrant world
==> dbsv: Running provisioner: shell...
dbsv: Running: inline script
dbsv: hello, db world
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant up websv
Bringing machine 'websv' up with 'virtualbox' provider...
==> websv: Importing base box 'centos/7'...
==> websv: Matching MAC address for NAT networking...
==> websv: Checking if box 'centos/7' version '1905.1' is up to date...
==> websv: Setting the name of the VM: webserver
==> websv: Fixed port collision for 22 => 2222. Now on port 2200.
==> websv: Clearing any previously set network interfaces...
==> websv: Preparing network interfaces based on configuration...
websv: Adapter 1: nat
websv: Adapter 2: bridged
==> websv: Forwarding ports...
websv: 22 (guest) => 2200 (host) (adapter 1)
==> websv: Running 'pre-boot' VM customizations...
==> websv: Booting VM...
==> websv: Waiting for machine to boot. This may take a few minutes...
websv: SSH address: 127.0.0.1:2200
websv: SSH username: vagrant
websv: SSH auth method: private key
websv:
websv: Vagrant insecure key detected. Vagrant will automatically replace
websv: this with a newly generated keypair for better security.
websv:
websv: Inserting generated public key within guest...
websv: Removing insecure key from the guest if it's present...
websv: Key inserted! Disconnecting and reconnecting using new SSH key...
==> websv: Machine booted and ready!
==> websv: Checking for guest additions in VM...
websv: No guest additions were detected on the base box for this VM! Guest
websv: additions are required for forwarded ports, shared folders, host only
websv: networking, and more. If SSH fails on this machine, please install
websv: the guest additions and repackage the box to continue.
websv:
websv: This is not an error message; everything may continue to work properly,
websv: in which case you may ignore this message.
==> websv: Setting hostname...
==> websv: Configuring and enabling network interfaces...
==> websv: Rsyncing folder: /cygdrive/c/vagrant/multi/ => /vagrant
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Vagrant world
==> websv: Running provisioner: shell...
websv: Running: inline script
websv: hello, Web world
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant ssh websv
[vagrant@websv ~]$
[vagrant@websv ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86378sec preferred_lft 86378sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.246/24 brd 192.168.1.255 scope global noprefixroute dynamic eth1
valid_lft 14379sec preferred_lft 14379sec
inet6 fe80::a00:27ff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
[vagrant@websv ~]$
[vagrant@websv ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant ssh dbsv
[vagrant@dbsv ~]$
[vagrant@dbsv ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 86142sec preferred_lft 86142sec
inet6 fe80::5054:ff:fe8a:fee6/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:00:00:02 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.31/24 brd 192.168.1.255 scope global noprefixroute dynamic eth1
valid_lft 14144sec preferred_lft 14144sec
inet6 fe80::a00:27ff:fe00:2/64 scope link
valid_lft forever preferred_lft forever
[vagrant@dbsv ~]$
[vagrant@dbsv ~]$ logout
Connection to 127.0.0.1 closed.
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant halt websv
==> websv: Attempting graceful shutdown of VM...
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant status websv
Current machine states:
websv poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant halt dbsv
==> dbsv: Attempting graceful shutdown of VM...
PS C:\vagrant\multi>
PS C:\vagrant\multi> vagrant status dbsv
Current machine states:
dbsv poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
PS C:\vagrant\multi>
付録¶
プラグインを使用した VB Guest Additions のインストール¶
vagrant up
コマンドで仮想マシンを起動したとき、 VB Guest Addtions がインストール済みか確認されます。インストールされていないと次のメッセージが表示されます。
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
Vagrant で作成した仮想マシンに VB Guest Additions をインストールするには次のコマンドを実行します。
以下の順番に実行します。
実行ログです。仮想マシンの 2 回目の起動時に次のメッセージが表示され、 VB Guest Addtions がインストール済みであることがわかります。
[default] GuestAdditions 6.1.2 running --- OK.
==> default: Checking for guest additions in VM...
PS C:\vagrant\my_centos> 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 '1905.1' is up to date...
==> default: Setting the name of the VM: node1
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
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: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
PS C:\vagrant\my_centos> vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: micromachine-3.0.0.gem (100%)
Fetching: vagrant-vbguest-0.23.0.gem (100%)
Installed the plugin 'vagrant-vbguest (0.23.0)'!
PS C:\vagrant\my_centos> vagrant vbguest
[default] No Virtualbox Guest Additions installation found.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package centos-release.x86_64 0:7-6.1810.2.el7.centos will be updated
---> Package centos-release.x86_64 0:7-7.1908.0.el7.centos will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
centos-release x86_64 7-7.1908.0.el7.centos base 26 k
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 26 k
Downloading packages:
No Presto metadata available for base
Public key for centos-release-7-7.1908.0.el7.centos.x86_64.rpm is not installed
warning: /var/cache/yum/x86_64/7/base/packages/centos-release-7-7.1908.0.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : centos-release-7-7.1908.0.el7.centos.x86_64 1/2
Cleanup : centos-release-7-6.1810.2.el7.centos.x86_64 2/2
Verifying : centos-release-7-7.1908.0.el7.centos.x86_64 1/2
Verifying : centos-release-7-6.1810.2.el7.centos.x86_64 2/2
Updated:
centos-release.x86_64 0:7-7.1908.0.el7.centos
Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:3.10.0-957.12.2.el7 will be installed
--> Processing Dependency: perl for package: kernel-devel-3.10.0-957.12.2.el7.x86_64
--> Running transaction check
---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-294.el7_6 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Running transaction check
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
--> Running transaction check
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel-devel x86_64 3.10.0-957.12.2.el7 C7.6.1810-updates 17 M
Installing for dependencies:
perl x86_64 4:5.16.3-294.el7_6 C7.6.1810-updates 8.0 M
perl-Carp noarch 1.26-244.el7 C7.0.1406-base 19 k
perl-Encode x86_64 2.51-7.el7 C7.0.1406-base 1.5 M
perl-Exporter noarch 5.68-3.el7 C7.0.1406-base 28 k
perl-File-Path noarch 2.09-2.el7 C7.0.1406-base 26 k
perl-File-Temp noarch 0.23.01-3.el7 C7.0.1406-base 56 k
perl-Filter x86_64 1.49-3.el7 C7.0.1406-base 76 k
perl-Getopt-Long noarch 2.40-3.el7 C7.5.1804-base 56 k
perl-HTTP-Tiny noarch 0.033-3.el7 C7.0.1406-base 38 k
perl-PathTools x86_64 3.40-5.el7 C7.0.1406-base 82 k
perl-Pod-Escapes noarch 1:1.04-294.el7_6 C7.6.1810-updates 51 k
perl-Pod-Perldoc noarch 3.20-4.el7 C7.0.1406-base 87 k
perl-Pod-Simple noarch 1:3.28-4.el7 C7.0.1406-base 216 k
perl-Pod-Usage noarch 1.63-3.el7 C7.0.1406-base 27 k
perl-Scalar-List-Utils x86_64 1.27-248.el7 C7.0.1406-base 36 k
perl-Socket x86_64 2.010-4.el7 C7.3.1611-base 49 k
perl-Storable x86_64 2.45-3.el7 C7.0.1406-base 77 k
perl-Text-ParseWords noarch 3.29-4.el7 C7.0.1406-base 14 k
perl-Time-HiRes x86_64 4:1.9725-3.el7 C7.0.1406-base 45 k
perl-Time-Local noarch 1.2300-2.el7 C7.0.1406-base 24 k
perl-constant noarch 1.27-2.el7 C7.0.1406-base 19 k
perl-libs x86_64 4:5.16.3-294.el7_6 C7.6.1810-updates 688 k
perl-macros x86_64 4:5.16.3-294.el7_6 C7.6.1810-updates 44 k
perl-parent noarch 1:0.225-244.el7 C7.0.1406-base 12 k
perl-podlators noarch 2.5.1-3.el7 C7.0.1406-base 112 k
perl-threads x86_64 1.87-4.el7 C7.0.1406-base 49 k
perl-threads-shared x86_64 1.43-6.el7 C7.0.1406-base 39 k
Transaction Summary
================================================================================
Install 1 Package (+27 Dependent packages)
Total download size: 28 M
Installed size: 74 M
Downloading packages:
--------------------------------------------------------------------------------
Total 1.6 MB/s | 28 MB 00:18
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:perl-parent-0.225-244.el7.noarch 1/28
Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 2/28
Installing : perl-podlators-2.5.1-3.el7.noarch 3/28
Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 4/28
Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 5/28
Installing : perl-Text-ParseWords-3.29-4.el7.noarch 6/28
Installing : perl-Encode-2.51-7.el7.x86_64 7/28
Installing : perl-Pod-Usage-1.63-3.el7.noarch 8/28
Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64 9/28
Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64 10/28
Installing : perl-Storable-2.45-3.el7.x86_64 11/28
Installing : perl-Exporter-5.68-3.el7.noarch 12/28
Installing : perl-constant-1.27-2.el7.noarch 13/28
Installing : perl-Time-Local-1.2300-2.el7.noarch 14/28
Installing : perl-Carp-1.26-244.el7.noarch 15/28
Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 16/28
Installing : perl-PathTools-3.40-5.el7.x86_64 17/28
Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 18/28
Installing : perl-File-Temp-0.23.01-3.el7.noarch 19/28
Installing : perl-File-Path-2.09-2.el7.noarch 20/28
Installing : perl-threads-shared-1.43-6.el7.x86_64 21/28
Installing : perl-threads-1.87-4.el7.x86_64 22/28
Installing : perl-Filter-1.49-3.el7.x86_64 23/28
Installing : perl-Socket-2.010-4.el7.x86_64 24/28
Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 25/28
Installing : perl-Getopt-Long-2.40-3.el7.noarch 26/28
Installing : 4:perl-5.16.3-294.el7_6.x86_64 27/28
Installing : kernel-devel-3.10.0-957.12.2.el7.x86_64 28/28
Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/28
Verifying : perl-threads-shared-1.43-6.el7.x86_64 2/28
Verifying : perl-Storable-2.45-3.el7.x86_64 3/28
Verifying : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 4/28
Verifying : perl-Exporter-5.68-3.el7.noarch 5/28
Verifying : perl-constant-1.27-2.el7.noarch 6/28
Verifying : perl-PathTools-3.40-5.el7.x86_64 7/28
Verifying : 1:perl-parent-0.225-244.el7.noarch 8/28
Verifying : 4:perl-libs-5.16.3-294.el7_6.x86_64 9/28
Verifying : perl-File-Temp-0.23.01-3.el7.noarch 10/28
Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 11/28
Verifying : perl-Time-Local-1.2300-2.el7.noarch 12/28
Verifying : 4:perl-macros-5.16.3-294.el7_6.x86_64 13/28
Verifying : 4:perl-5.16.3-294.el7_6.x86_64 14/28
Verifying : perl-Carp-1.26-244.el7.noarch 15/28
Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 16/28
Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 17/28
Verifying : perl-Pod-Usage-1.63-3.el7.noarch 18/28
Verifying : kernel-devel-3.10.0-957.12.2.el7.x86_64 19/28
Verifying : perl-Encode-2.51-7.el7.x86_64 20/28
Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 21/28
Verifying : perl-podlators-2.5.1-3.el7.noarch 22/28
Verifying : perl-File-Path-2.09-2.el7.noarch 23/28
Verifying : perl-threads-1.87-4.el7.x86_64 24/28
Verifying : perl-Filter-1.49-3.el7.x86_64 25/28
Verifying : perl-Getopt-Long-2.40-3.el7.noarch 26/28
Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 27/28
Verifying : perl-Socket-2.010-4.el7.x86_64 28/28
Installed:
kernel-devel.x86_64 0:3.10.0-957.12.2.el7
Dependency Installed:
perl.x86_64 4:5.16.3-294.el7_6
perl-Carp.noarch 0:1.26-244.el7
perl-Encode.x86_64 0:2.51-7.el7
perl-Exporter.noarch 0:5.68-3.el7
perl-File-Path.noarch 0:2.09-2.el7
perl-File-Temp.noarch 0:0.23.01-3.el7
perl-Filter.x86_64 0:1.49-3.el7
perl-Getopt-Long.noarch 0:2.40-3.el7
perl-HTTP-Tiny.noarch 0:0.033-3.el7
perl-PathTools.x86_64 0:3.40-5.el7
perl-Pod-Escapes.noarch 1:1.04-294.el7_6
perl-Pod-Perldoc.noarch 0:3.20-4.el7
perl-Pod-Simple.noarch 1:3.28-4.el7
perl-Pod-Usage.noarch 0:1.63-3.el7
perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
perl-Socket.x86_64 0:2.010-4.el7
perl-Storable.x86_64 0:2.45-3.el7
perl-Text-ParseWords.noarch 0:3.29-4.el7
perl-Time-HiRes.x86_64 4:1.9725-3.el7
perl-Time-Local.noarch 0:1.2300-2.el7
perl-constant.noarch 0:1.27-2.el7
perl-libs.x86_64 4:5.16.3-294.el7_6
perl-macros.x86_64 4:5.16.3-294.el7_6
perl-parent.noarch 1:0.225-244.el7
perl-podlators.noarch 0:2.5.1-3.el7
perl-threads.x86_64 0:1.87-4.el7
perl-threads-shared.x86_64 0:1.43-6.el7
Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Package 4:perl-5.16.3-294.el7_6.x86_64 already installed and latest version
Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.27-34.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-41.base.el7_7.2 will be an update
---> Package elfutils-libelf-devel.x86_64 0:0.176-2.el7 will be installed
--> Processing Dependency: elfutils-libelf(x86-64) = 0.176-2.el7 for package: elfutils-libelf-devel-0.176-2.el7.x86_64
--> Processing Dependency: pkgconfig(zlib) for package: elfutils-libelf-devel-0.176-2.el7.x86_64
---> Package gcc.x86_64 0:4.8.5-39.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-39.el7.x86_64
---> Package make.x86_64 1:3.82-23.el7 will be updated
---> Package make.x86_64 1:3.82-24.el7 will be an update
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-39.el7 will be installed
---> Package elfutils-libelf.x86_64 0:0.172-2.el7 will be updated
--> Processing Dependency: elfutils-libelf(x86-64) = 0.172-2.el7 for package: elfutils-libs-0.172-2.el7.x86_64
---> Package elfutils-libelf.x86_64 0:0.176-2.el7 will be an update
---> Package glibc-devel.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-292.el7.x86_64
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgcc.x86_64 0:4.8.5-39.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgomp.x86_64 0:4.8.5-39.el7 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Running transaction check
---> Package elfutils-libs.x86_64 0:0.172-2.el7 will be updated
---> Package elfutils-libs.x86_64 0:0.176-2.el7 will be an update
---> Package glibc.x86_64 0:2.17-260.el7_6.5 will be updated
--> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-common-2.17-260.el7_6.5.x86_64
---> Package glibc.x86_64 0:2.17-292.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-292.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-292.el7.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-260.el7_6.5 will be updated
---> Package glibc-common.x86_64 0:2.17-292.el7 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1062.12.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
elfutils-libelf-devel x86_64 0.176-2.el7 base 39 k
gcc x86_64 4.8.5-39.el7 base 16 M
Updating:
binutils x86_64 2.27-41.base.el7_7.2 updates 5.9 M
make x86_64 1:3.82-24.el7 base 421 k
Installing for dependencies:
cpp x86_64 4.8.5-39.el7 base 5.9 M
glibc-devel x86_64 2.17-292.el7 base 1.1 M
glibc-headers x86_64 2.17-292.el7 base 687 k
kernel-headers x86_64 3.10.0-1062.12.1.el7 updates 8.7 M
libmpc x86_64 1.0.1-3.el7 base 51 k
mpfr x86_64 3.1.1-4.el7 base 203 k
zlib-devel x86_64 1.2.7-18.el7 base 50 k
Updating for dependencies:
elfutils-libelf x86_64 0.176-2.el7 base 194 k
elfutils-libs x86_64 0.176-2.el7 base 291 k
glibc x86_64 2.17-292.el7 base 3.6 M
glibc-common x86_64 2.17-292.el7 base 11 M
libgcc x86_64 4.8.5-39.el7 base 102 k
libgomp x86_64 4.8.5-39.el7 base 158 k
Transaction Summary
================================================================================
Install 2 Packages (+7 Dependent packages)
Upgrade 2 Packages (+6 Dependent packages)
Total download size: 55 M
Downloading packages:
No Presto metadata available for base
No Presto metadata available for updates
--------------------------------------------------------------------------------
Total 11 MB/s | 55 MB 00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libgcc-4.8.5-39.el7.x86_64 1/25
Updating : glibc-2.17-292.el7.x86_64 2/25
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
Updating : glibc-common-2.17-292.el7.x86_64 3/25
Installing : mpfr-3.1.1-4.el7.x86_64 4/25
Installing : libmpc-1.0.1-3.el7.x86_64 5/25
Updating : elfutils-libelf-0.176-2.el7.x86_64 6/25
Installing : cpp-4.8.5-39.el7.x86_64 7/25
Updating : binutils-2.27-41.base.el7_7.2.x86_64 8/25
Updating : libgomp-4.8.5-39.el7.x86_64 9/25
Installing : kernel-headers-3.10.0-1062.12.1.el7.x86_64 10/25
Installing : glibc-headers-2.17-292.el7.x86_64 11/25
Installing : glibc-devel-2.17-292.el7.x86_64 12/25
Installing : zlib-devel-1.2.7-18.el7.x86_64 13/25
Installing : elfutils-libelf-devel-0.176-2.el7.x86_64 14/25
Installing : gcc-4.8.5-39.el7.x86_64 15/25
Updating : elfutils-libs-0.176-2.el7.x86_64 16/25
Updating : 1:make-3.82-24.el7.x86_64 17/25
Cleanup : elfutils-libs-0.172-2.el7.x86_64 18/25
Cleanup : elfutils-libelf-0.172-2.el7.x86_64 19/25
Cleanup : libgomp-4.8.5-36.el7_6.2.x86_64 20/25
Cleanup : 1:make-3.82-23.el7.x86_64 21/25
Cleanup : binutils-2.27-34.base.el7.x86_64 22/25
Cleanup : glibc-common-2.17-260.el7_6.5.x86_64 23/25
Cleanup : glibc-2.17-260.el7_6.5.x86_64 24/25
Cleanup : libgcc-4.8.5-36.el7_6.2.x86_64 25/25
Verifying : binutils-2.27-41.base.el7_7.2.x86_64 1/25
Verifying : mpfr-3.1.1-4.el7.x86_64 2/25
Verifying : gcc-4.8.5-39.el7.x86_64 3/25
Verifying : zlib-devel-1.2.7-18.el7.x86_64 4/25
Verifying : 1:make-3.82-24.el7.x86_64 5/25
Verifying : libgomp-4.8.5-39.el7.x86_64 6/25
Verifying : glibc-common-2.17-292.el7.x86_64 7/25
Verifying : libgcc-4.8.5-39.el7.x86_64 8/25
Verifying : cpp-4.8.5-39.el7.x86_64 9/25
Verifying : elfutils-libelf-devel-0.176-2.el7.x86_64 10/25
Verifying : libmpc-1.0.1-3.el7.x86_64 11/25
Verifying : glibc-2.17-292.el7.x86_64 12/25
Verifying : kernel-headers-3.10.0-1062.12.1.el7.x86_64 13/25
Verifying : glibc-devel-2.17-292.el7.x86_64 14/25
Verifying : elfutils-libs-0.176-2.el7.x86_64 15/25
Verifying : elfutils-libelf-0.176-2.el7.x86_64 16/25
Verifying : glibc-headers-2.17-292.el7.x86_64 17/25
Verifying : binutils-2.27-34.base.el7.x86_64 18/25
Verifying : libgcc-4.8.5-36.el7_6.2.x86_64 19/25
Verifying : libgomp-4.8.5-36.el7_6.2.x86_64 20/25
Verifying : glibc-common-2.17-260.el7_6.5.x86_64 21/25
Verifying : glibc-2.17-260.el7_6.5.x86_64 22/25
Verifying : elfutils-libelf-0.172-2.el7.x86_64 23/25
Verifying : 1:make-3.82-23.el7.x86_64 24/25
Verifying : elfutils-libs-0.172-2.el7.x86_64 25/25
Installed:
elfutils-libelf-devel.x86_64 0:0.176-2.el7 gcc.x86_64 0:4.8.5-39.el7
Dependency Installed:
cpp.x86_64 0:4.8.5-39.el7
glibc-devel.x86_64 0:2.17-292.el7
glibc-headers.x86_64 0:2.17-292.el7
kernel-headers.x86_64 0:3.10.0-1062.12.1.el7
libmpc.x86_64 0:1.0.1-3.el7
mpfr.x86_64 0:3.1.1-4.el7
zlib-devel.x86_64 0:1.2.7-18.el7
Updated:
binutils.x86_64 0:2.27-41.base.el7_7.2 make.x86_64 1:3.82-24.el7
Dependency Updated:
elfutils-libelf.x86_64 0:0.176-2.el7 elfutils-libs.x86_64 0:0.176-2.el7
glibc.x86_64 0:2.17-292.el7 glibc-common.x86_64 0:2.17-292.el7
libgcc.x86_64 0:4.8.5-39.el7 libgomp.x86_64 0:4.8.5-39.el7
Complete!
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 6.1.2 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.2 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel
3.10.0-957.12.2.el7.x86_64.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> 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: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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 aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
[default] GuestAdditions 6.1.2 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/c/vagrant/my_centos/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\vagrant\my_centos>
PS C:\vagrant\my_centos> vagrant halt
==> default: Attempting graceful shutdown of VM...
PS C:\vagrant\my_centos>
VB Guest Additions の手動インストール¶
vagrant ssh
コマンドで接続し、次のコマンドを実行します。sudo yum -y update
sudo yum -y install wget
sudo yum -y groupinstall 'Development tools'
wget http://download.virtualbox.org/virtualbox/6.1.2/VBoxGuestAdditions_6.1.2.iso
sudo mkdir /media/iso
sudo shutdown -r now
sudo yum -y install kernel-devel
sudo mount -o loop,ro VBoxGuestAdditions_6.1.2.iso /media/iso
sudo sh /media/iso/VBoxLinuxAdditions.run
重要
VB Guest Additions は VirtulBox のバージョンごとに用意されています。下記の URL でお使いの VirutualBox のバージョンにあった VB Guest Additions をご使用ください。
IEEE が管理しているプライベート用 MAC アドレス( 2020 年 2 月 9 日 確認)¶
改版履歴¶
2020-02-14 初版作成 / 公開