- 追加された行はこの色です。
- 削除された行はこの色です。
[[FrontPage]]
#author("2021-12-14T02:35:04+00:00","","")
// 一覧用テンプレート
#topicpath
----
#ls2
#contents
** インストール [#jc9e6847]
MacだとbrewでVirtualBoxとともに入れるのがイイかな
-[[Homebrew CaskでVagrantの環境構築メモ - Qiita>http://qiita.com/moomooya/items/30f9ffdb7dd34caf9ec0]]
2018/04/23追記: と思ったけど https://www.vagrantup.com/docs/installation/ ここみるとぜひオフィシャルのインストーラを使えと。
あとはVirtualBoxもわすれずに。。。
https://www.virtualbox.org/wiki/Downloads
** Boxのダウンロード、一覧、削除 [#kbe36769]
http://www.vagrantbox.es/ からboxを探して
$ vagrant box add ubuntu/xenial64
==> box: Loading metadata for box 'ubuntu/xenial64'
box: URL: https://vagrantcloud.com/ubuntu/xenial64
==> box: Adding box 'ubuntu/xenial64' (v20180420.0.0) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180420.0.0/providers/virtualbox.box
==> box: Successfully added box 'ubuntu/xenial64' (v20180420.0.0) for 'virtualbox'!
$ vagrant box add https://atlas.hashicorp.com/envimation/boxes/ubuntu-xenial
==> box: Loading metadata for box 'https://atlas.hashicorp.com/envimation/boxes/ubuntu-xenial'
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) virtualbox
2) vmware_desktop
Enter your choice: 1
==> box: Adding box 'envimation/ubuntu-xenial' (v1.0.3-1498871542) for provider: virtualbox
box: Downloading: https://app.vagrantup.com/envimation/boxes/ubuntu-xenial/versions/1.0.3-1498871542/providers/virtualbox.box
==> box: Successfully added box 'envimation/ubuntu-xenial' (v1.0.3-1498871542) for 'virtualbox'!
$
でダウンロード完了
一覧表示
$ vagrant box list
envimation/ubuntu-xenial (virtualbox, 1.0.3-1498871542)
$
ubuntu/xenial64 (virtualbox, 20180420.0.0)
削除
$ vagrant box remove envimation/ubuntu-xenial
イメージの削除
$ vagrant box remove ubuntu/xenial64
で削除。ちなみにイメージは、
$ ls -lrt ~/.vagrant.d/boxes/
total 0
drwxr-xr-x 4 masatomix staff 136 7 1 11:59 envimation-VAGRANTSLASH-ubuntu-xenial
drwxr-xr-x 4 masatomix staff 136 7 1 11:59 ubuntu-VAGRANTSLASH-xenial64
$
ココ。
**試しにUbuntuをインストール [#ifff3d55]
$ mkdir ubuntu && cd $_
/Users/masatomix/Desktop/ubuntu
$ vagrant init envimation/ubuntu-xenial
$ vagrant init ubuntu/xenial64
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.
$ ls -lrt Vagrantfile
-rw-r--r-- 1 masatomix staff 3031 7 1 12:04 Vagrantfile
起動
OS起動
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'envimation/ubuntu-xenial'...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'envimation/ubuntu-xenial' is up to date...
==> default: Setting the name of the VM: ubuntu_default_1498878490997_69625
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: ubuntu_default_1524405925055_36290
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> 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: 22 (guest) => 2200 (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 address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
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: Mounting shared folders...
default: /vagrant => /Users/masatomix/Desktop/ubuntu
iMac5K:ubuntu masatomix$
$
OSが起動しました。
$ vagrant ssh
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-119-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
vagrant@ubuntu-xenial:~$
ログインできました。
ステータス
$ vagrant status
Current machine states:
default running (virtualbox)
一時停止
$ vagrant suspend
$ vagrant status
Current machine states:
default saved (virtualbox)
$ vagrant resume
$ vagrant status
Current machine states:
default running (virtualbox)
停止
$ vagrant halt
$ vagrant status
Current machine states:
default poweroff (virtualbox)
$
** IPをNATでなくてBridgeにする [#ab67ceb3]
[[環境変数で Vagrant の bridge を指定できるようにする - Qiita>https://qiita.com/elim/items/816f03c732e4b274d181]] こちらからの情報そのまんまですが、デフォルトだとネットワーク設定がNAT設定になってしまいますが、Bridgeにするには Vagrantfile に以下を追加します。
# SHELL
# ココから
if ENV['VAGRANT_BRIDGE']
interfaces = %x(VBoxManage list bridgedifs)
re = /Name: +(.*#{ENV['VAGRANT_BRIDGE']}.*)/
if interfaces =~ re
config.vm.network :public_network, bridge: $1
end
end
# ココまで
end
起動時に以下の環境設定を追加します。
VAGRANT_BRIDGE=Wi-Fi vagrant up
**関連リンク [#q027ed0f]
-[[Discover Vagrant Boxes - Vagrant Cloud>https://app.vagrantup.com/boxes/search]] イメージの公式?
-[[【Vagrantドキュメント意訳】09.プロビジョニング - Qiita>https://qiita.com/ringo0321/items/38743442a9abfc3be5b2]]
-[[Vagrant 入門: インストールとセットアップ « をぶろぐ>http://tetsuwo.tumblr.com/post/85636464262/vagrant-install-setting]]
-[[Vagrantを扱うときにハマりがちポイントをまとめてみた - Qiita>https://qiita.com/srockstyle/items/233ef326a75362200a91]]
----
この記事は
#vote(おもしろかった[2],そうでもない[0])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}