LoginSignup
2
2

More than 5 years have passed since last update.

[WIP] Vagrant Getting Started 日本語訳

Posted at

原文 https://www.vagrantup.com/intro/getting-started/index.html
自分用のメモとして残しておきます。全体的にむずかしい言い回しの多い文章でまともに訳せてる気がしないので、ツッコミ歓迎です。

Getting Started - 入門

The Vagrant getting started guide will walk you through your first Vagrant project, and show off the basics of the major features Vagrant has to offer.

Vagrant入門ガイドでは、Vagrantプロジェクトのはじめかたを一通り説明し、Vagrantが提供している主な機能の基本的な使い方を紹介します。

If you are curious what benefits Vagrant has to offer, you should also read the "Why Vagrant?" page.

Vagrantを使うとどんな利点があるのかを知りたい場合は、「なぜVagrantを使うのか」を読むべきです。

The getting started guide will use Vagrant with VirtualBox, since it is free, available on every major platform, and built-in to Vagrant.

入門ガイドでは、VirtualBoxでVagrantを使用します。
VirtualBoxは無料で、あらゆる主要なプラットフォームで利用可能で、Vagrantに組み込まれているからです。

After reading the guide though, do not forget that Vagrant can work with many other providers.

このガイドにはVirtualBoxのことしか書いていませんが、Vagrantは他の様々な「プロバイダ」と一緒に使えることを忘れないであげてください。

Before diving into your first project, please install the latest version of Vagrant.

最初のプロジェクトをはじめる前に、最新バージョンのVagrantをインストールしてください。

And because we will be using VirtualBox as our provider for the getting started guide, please install that as well.

また、入門ガイドで用いるプロバイダとしてVirtualBoxを使用するため、これもインストールしてください。

More of a book person?

書籍派ですか?

If you prefer to read a physical book, you may be interested in Vagrant: Up and Running, written by the author of Vagrant and published by O'Reilly.

紙の本を読むのが好きな人は、Vagrantの開発者が書いたO'Reilly出版の"Vagrant: Up and Running"をお勧めします。

Up and Running - 起動と実行

$ vagrant init hashicorp/precise64
$ vagrant up

After running the above two commands, you will have a fully running virtual machine in VirtualBox running Ubuntu 12.04 LTS 64-bit.

上記の2つのコマンドを実行すると、Ubuntu 12.04 LTS 64ビットを実行している仮想マシンがVirtualBox上に作成されます。
(a fully running virtual machine が何を意味してるのかよくわからない)

You can SSH into this machine with vagrant ssh, and when you are done playing around, you can terminate the virtual machine with vagrant destroy.

この仮想マシンにvagrant sshでログインできます。
用が済んだら、vagrant destroyで仮想マシンを終了することができます。

Now imagine every project you've ever worked on being this easy to set up!

さあ、いままでやってきた全てのプロジェクトがこの簡単な手順でセットアップできると想像してみてください!

With Vagrant, vagrant up is all you need to work on any project, to install every dependency that project needs, and to set up any networking or synced folders, so you can continue working from the comfort of your own machine.

Vagrantがあれば、プロジェクトに必要な全ての依存関係のインストールも、ネットワークやフォルダのセットアップも、vagrant upで全てできます。
つまり、自分のマシンのような快適さで作業できるわけです。(?????)

The rest of this guide will walk you through setting up a more complete project, covering more features of Vagrant.

あとに続く章では、Vagrantのより多くの機能を網羅した、より完全なプロジェクトを設定する方法について説明します。

Next Steps - 次のステップ

You have just created your first virtual environment with Vagrant.

この章では、Vagrantを使用して最初の仮想環境を作成しました。

Read on to learn more about project setup.

次の章では、プロジェクトのセットアップについてもう少し詳しく見ていきましょう。

Project Setup - プロジェクトのセットアップ

The first step in configuring any Vagrant project is to create a Vagrantfile.

Vagrantプロジェクトを設定するための最初の手順は、Vagrantfileを作成することです。

The purpose of the Vagrantfile is twofold:

Vagrantfileの目的は2つあります

  1. Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.

プロジェクトのルートディレクトリをマークします。 Vagrantの設定オプションの多くは、このルートディレクトリに関連づけられています。

  1. Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.

プロジェクトを実行するために必要なマシンとリソースの種類、インストールするソフトウェア、アクセス方法について記述します。

Vagrant has a built-in command for initializing a directory for usage with Vagrant: vagrant init.

Vagrantには、Vagrantで使用するためにディレクトリを初期化するコマンドが組み込まれています。
vagrant initです。

For the purpose of this getting started guide, please follow along in your terminal:

この入門ガイド用のディレクトリを初期化するには、ターミナルで次のように入力してください。

$ mkdir vagrant_getting_started
$ cd vagrant_getting_started
$ vagrant init

This will place a Vagrantfile in your current directory.

これはカレントディレクトリにVagrantfileを配置します。

You can take a look at the Vagrantfile if you want, it is filled with comments and examples.

気になるなら作成されたVagrantfileを覗いてみましょう。
コメントや例が書かれていると思います。

Do not be afraid if it looks intimidating, we will modify it soon enough.

このあとすぐ編集方法を説明するので、怖がらなくても大丈夫です。

You can also run vagrant init in a pre-existing directory to set up Vagrant for an existing project.

既に存在するディレクトリの中でvagrant initを実行して、既存のプロジェクトでVagrantをセットアップすることも可能です。

The Vagrantfile is meant to be committed to version control with your project, if you use version control.

バージョンコントロールを使っている場合、Vagrantfileはプロジェクトのファイルと一緒にコミットされることを意図してつくられています。

This way, every person working with that project can benefit from Vagrant without any upfront work.

この場合、全てのプロジェクトメンバーが事前作業なしにVagrantの恩恵をうけることができます。

Next Steps

You have successfully created your first project environment.

最初のプロジェクトの環境が作成できたと思います。

Read on to learn more about Vagrant boxes.

次は、Vagrant boxについて詳しく見ていきましょう。

Boxes

Instead of building a virtual machine from scratch, which would be a slow and tedious process, Vagrant uses a base image to quickly clone a virtual machine.

仮想マシンをいちから構築する(それは退屈で時間のかかるプロセスです)のではなく、Vagrantはベースイメージを使って迅速に仮想マシンのコピーを作成します。

These base images are known as "boxes" in Vagrant, and specifying the box to use for your Vagrant environment is always the first step after creating a new Vagrantfile.

これらのベースイメージはVagrantの「ボックス」として知られており、あなたのVagrant環境に使用するボックスを指定することは常に、新しいVagrantfileを作成した後の最初のステップです。

Installing a Box - Boxのインストール

If you ran the commands on the getting started overview page, then you've already installed a box before, and you do not need to run the commands below again.

入門ガイドの概要ページでコマンドを実行した場合、既にboxはインストールされているので、以下のコマンドを再度実行する必要はありません。

However, it is still worth reading this section to learn more about how boxes are managed.

しかし、ボックスの管理方法の詳細については、このセクションを読む価値があります。

Boxes are added to Vagrant with vagrant box add.

boxの追加はvagrant box addで行うことができます。

This stores the box under a specific name so that multiple Vagrant environments can re-use it.

このコマンドは、複数のVagrant環境で再利用できるように、特定の名前のもとにboxを保存します。

If you have not added a box yet, you can do so now:

まだboxを追加していない場合は、次のコマンドでこれを行うことができます。

$ vagrant box add hashicorp/precise64

This will download the box named "hashicorp/precise64" from HashiCorp's Vagrant Cloud box catalog, a place where you can find and host boxes.

HashiCorpのVagrant Cloudボックスカタログ(ここでboxのホスティングや検索ができます)から "hashicorp/precise64" という名前のボックスがダウンロードされます。

While it is easiest to download boxes from HashiCorp's Vagrant Cloud you can also add boxes from a local file, custom URL, etc.

HashCorpのVagrant Cloudからボックスをダウンロードするのが最も簡単ですが、ローカルファイルやカスタムURLなどからボックスを追加することもできます

Boxes are globally stored for the current user. Each project uses a box as an initial image to clone from, and never modifies the actual base image. This means that if you have two projects both using the hashicorp/precise64 box we just added, adding files in one guest machine will have no effect on the other machine.

In the above command, you will notice that boxes are namespaced. Boxes are broken down into two parts - the username and the box name - separated by a slash. In the example above, the username is "hashicorp", and the box is "precise64". You can also specify boxes via URLs or local file paths, but that will not be covered in the getting started guide.

Namespaces do not guarantee canonical boxes! A common misconception is that a namespace like "ubuntu" represents the canonical space for Ubuntu boxes. This is untrue. Namespaces on Vagrant Cloud behave very similarly to namespaces on GitHub, for example. Just as GitHub's support team is unable to assist with issues in someone's repository, HashiCorp's support team is unable to assist with third-party published boxes.

Using a Box

Now that the box has been added to Vagrant, we need to configure our project to use it as a base. Open the Vagrantfile and change the contents to the following:

Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
end

The "hashicorp/precise64" in this case must match the name you used to add the box above. This is how Vagrant knows what box to use. If the box was not added before, Vagrant will automatically download and add the box when it is run.

You may specify an explicit version of a box by specifying config.vm.box_version for example:

Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.box_version = "1.1.0"
end

You may also specify the URL to a box directly using config.vm.box_url:

Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.box_url = "https://vagrantcloud.com/hashicorp/precise64"
end

In the next section, we will bring up the Vagrant environment and interact with it a little bit.

Finding More Boxes

For the remainder of this getting started guide, we will only use the "hashicorp/precise64" box we added previously. But soon after finishing this getting started guide, the first question you will probably have is "where do I find more boxes?"

The best place to find more boxes is HashiCorp's Vagrant Cloud box catalog. HashiCorp's Vagrant Cloud has a public directory of freely available boxes that run various platforms and technologies. HashiCorp's Vagrant Cloud also has a great search feature to allow you to find the box you care about.

In addition to finding free boxes, HashiCorp's Vagrant Cloud lets you host your own boxes, as well as private boxes if you intend on creating boxes for your own organization.

Next Steps

You have successfully downloaded your first Vagrant box and configured the Vagrantfile to utilize that box. Read on to learn about bringing up and access the Vagrant machine via SSH.

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2