MacにVirtualBoxとVagrantを入れて、Debian 9 "Stretch"を立ち上げる

タイトルの通り、MacVirtualBoxVagrantを入れて、Debian 9 “Stretch"を立ち上げていきます。

今回の環境

ホストOS
macOS Sierra 10.12.5 (16F73)
VirtualBox
5.1.22 r115126 (Qt5.6.2)
Vagrant
1.9.5
ゲストOS
Debian 9.0 "Stretch"

VirtualBoxのインストー

https://www.virtualbox.orgのDownloadsページから、OS X hostsのバイナリー、VirtualBox-5.1.22-115126-OSX.dmgをダウンロードしてインストールしました。

f:id:satomi-san:20170627234940j:plain

Vagrantのインストー

https://www.vagrantup.comのDownloadsページから、Mac OS X Universal (32 and 64-bit)の、vagrant_1.9.5_x86_64.dmgをダウンロードしてインストールしました。

Debian 9 “Stretch”

Discover Vagrant Boxes | Atlas by HashiCorp で、debianのboxを探してみると、debian/stretch64が公開されていましたので、これを使わせてもらいます。

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

続いて起動です。自動的にboxをDLしてくれます。

$ vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'debian/stretch64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'debian/stretch64'
    default: URL: https://atlas.hashicorp.com/debian/stretch64
==> default: Adding box 'debian/stretch64' (v9.0.0) for provider: virtualbox
    default: Downloading: https://atlas.hashicorp.com/debian/boxes/stretch64/versions/9.0.0/providers/virtualbox.box
==> default: Successfully added box 'debian/stretch64' (v9.0.0) for 'virtualbox'!
==> default: Importing base box 'debian/stretch64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'debian/stretch64' is up to date...
==> default: Setting the name of the VM: ansible_default_1498577443083_48557
==> 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: 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: Installing rsync to the VM...
==> default: Rsyncing folder: /Users/*****/ansible/ => /vagrant

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default: 
==> default: Vanilla Debian box. See https://atlas.hashicorp.com/debian/ for help and bug reports

無事起動できました。

f:id:satomi-san:20170628003737j:plain