ツナワタリマイライフ

日常ネタから技術ネタ、音楽ネタまで何でも書きます。

VagrantのBoxのVERSIONINGについて公式サイトを日本語訳する

はじめに

前回の記事(vagrantのVMをpackageを使ってBox化する - ツナワタリマイライフ)でBoxのバージョニングについて知ったので今回は公式ドキュメントを日本語訳してみる。

https://www.vagrantup.com/docs/boxes/versioning.html

BOX VERSIONING

Boxのバージョニング

Since Vagrant 1.5, boxes support versioning. This allows the people who make boxes to push updates to the box, and the people who use the box have a simple workflow for checking for updates, updating their boxes, and seeing what has changed.

Vagrantのversion1.5から、boxはバージョニングをサポートします。これはboxの作成者にboxのアップデートを可能にし、boxの利用者にシンプルな手順で更新の確認と、boxの更新と、変更を確認を可能にします。

If you are just getting started with Vagrant, box versioning is not too important, and we recommend learning about some other topics first. But if you are using Vagrant on a team or plan on creating your own boxes, versioning is very important. Luckily, having versioning built right in to Vagrant makes it easy to use and fit nicely into the Vagrant workflow.

もしあなたがVagrantをはじめたばかりなら、boxのバージョニングはそんなに重要じゃないでしょう。我々は他のトピックを先に学ぶことをおすすめします。しかしあなたがVagrantをそれなりの期間使う、もしくは自分自身でboxを作成しようとしているのであれば、バージョニングはとても重要です。幸運なことに、vagrantにバージョニングを組み込むことはvagrantのワークフローにとてもよく馴染みます。

This page will cover how to use versioned boxes. It does not cover how to update your own custom boxes with versions. That is covered in creating a base box.

このページはバージョニングされたboxの使い方を説明します。あなた自身のboxのバージョンの更新方法については説明しません。それはbase boxの作り方のページで説明しています。

VIEWING VERSIONS AND UPDATING

versionとupdateを確認する

vagrant box list only shows installed versions of boxes. If you want to see all available versions of a box, you will have to find the box on HashiCorp's Atlas. An easy way to find a box is to use the url https://atlas.hashicorp.com/$USER/$BOX. For example, for the hashicorp/precise64 box, you can find information about it at https://atlas.hashicorp.com/hashicorp/precise64.

"vagrant box list"コマンドではインストールされたboxのバージョンしか表示しません。もしあなたが利用可能なboxのversionを全て見たい場合は、HashiCorp's Atlasのboxを見ましょう。boxを探す簡単な方法は「https://atlas.hashicorp.com/$USER/$BOX.」というurlを使うことです。例えば、hashicorp/precise64というboxであれば、あなたは「https://atlas.hashicorp.com/hashicorp/precise64.」から情報を得ることができるでしょう。

You can check if the box you are using is outdated with vagrant box outdated. This can check if the box in your current Vagrant environment is outdated as well as any other box installed on the system.

あなたは"vagrant box outdated"を使って使用しているboxが期限切れかどうかを確認できます。これはシステムにインストールされた他のboxも同じようにあなたの現在のvagrant環境のboxが期限切れかどうかを確認できます。

Finally, you can update boxes with vagrant box update. This will download and install the new box. This will not magically update running Vagrant environments. If a Vagrant environment is already running, you will have to destroy and recreate it to acquire the new updates in the box. The update command just downloads these updates locally.

最後に、あなたは"vagrant box update"でboxを更新できます。これは新しいboxをダウンロードしてインストールするでしょう。これは動作しているvagrantの環境が魔法のように更新されるわけではありません。もしvagrantの環境が既に動作しているなら、あなたはboxの更新を破棄して作りなおさなければいけません。updateコマンドは単にローカル環境に更新をダウンロードするだけです。

VERSION CONSTRAINTS

バージョンの制約

You can constrain a Vagrant environment to a specific version or versions of a box using the Vagrantfile by specifying the config.vm.box_version option.

あなたはvagrant環境に対して "config.vm.box_version"オプションを使ったVagrantfileを使ってboxのバージョンを制限することができます。

If this option is not specified, the latest version is always used. This is equivalent to specifying a constraint of ">= 0".

このオプションはデフォルトでは最新バージョンが使われます。これは0以上の制約を特定していることと等価です。

The box version configuration can be a specific version or a constraint of versions. Constraints can be any combination of the following: = X, > X, < X, >= X, <= X, ~> X. You can combine multiple constraints by separating them with commas. All the constraints should be self explanatory except perhaps for ~>, known as the "pessimistic constraint". Examples explain it best: ~> 1.0 is equivalent to >= 1.0, < 2.0. And ~> 1.1.5 is equivalent to >= 1.1.5, < 1.2.0.

boxのバージョン設定はバージョンもしくはバージョンの制約を特定できます。制約は>,<,>=,~<の組み合わせに従います。コンマ区切りで複数の制約を組み合わせることができます。全ての制約は「悲観的な制約」として知られる>~のフレーズを期待します。例えて言うなら、~>1.0は1.0以上で2.0より小さいことを意味します。そして~>1.1.5は1.1.5以上で1.2.0以下を意味します。

You can choose to handle versions however you see fit. However, many boxes in the public catalog follow semantic versioning. Basically, only the first number (the "major version") breaks backwards compatibility. In terms of Vagrant boxes, this means that any software that runs in version "1.1.5" of a box should work in "1.2" and "1.4.5" and so on, but "2.0" might introduce big changes that break your software. By following this convention, the best constraint is ~> 1.0 because you know it is safe no matter what version is in that range.

あなたは自由にバージョンの扱いを選ぶことができます。しかし、多くの公開されているboxは意味を持ったバージョニングに従います。基本的に、最初の数字(メジャーバージョンという)だけが後方互換性を破ります。vagrantのboxについても、boxの1.1.5のバージョンで動いているソフトウェアは1.2で動くべきだし、1.4.5でも動くべきです。しかし2.0はあなたのソフトウェアを破壊するような大きな変更があるかもしれません。この規則に従うと、ベストな制約は~1.0です。その範囲内のどのバージョンも安全だと知っているからです。

Please note that, while the semantic versioning specification allows for more than three points and pre-release or beta versions, Vagrant boxes must be of the format X.Y.Z where X, Y, and Z are all positive integers.

気をつけて欲しいのは、プレリリース、もしくはβバージョンは3点より多くの数値を許可することに対し、vagrantのバージョンは正の整数X,Y,ZによるX.Y.Zの形式しか許さないことです。

AUTOMATIC UPDATE CHECKING

自動的に更新をチェックする

Using the Vagrantfile, you can also configure Vagrant to automatically check for updates during any vagrant up. This is enabled by default, but can easily be disabled with config.vm.box_check_update = false in your Vagrantfile.

Vagrantfileを使って、あなたはvagrantに、vagrant upしている間に更新のチェックを自動的にさせることもできます。これはデフォルトで有効になっていますが、config.vm.box_check_update=falseとすることで簡単に無効にできます。

When this is enabled, Vagrant will check for updates on every vagrant up, not just when the machine is being created from scratch, but also when it is resuming, starting after being halted, etc.

これが有効なときは、vagrantvagrant upするごとに更新を確認するでしょう。仮想マシンをゼロから作成したときだけでなく、停止したあと再起動するときも確認します。

If an update is found, Vagrant will output a warning to the user letting them know an update is available. That user can choose to ignore the warning for now, or can update the box by running vagrant box update.

更新が見つかったら、vagrantは更新が有効であることを知らせるワーニングを出力するでしょう。ユーザはワーニングを無視することもできますし、更新することもできます。

Vagrant can not and does not automatically download the updated box and update the machine because boxes can be relatively large and updating the machine requires destroying it and recreating it, which can cause important data to be lost. Therefore, this process is manual to the extent that the user has to manually enter a command to do it.

vagrantは更新されたboxをダウンロードして仮想マシンを更新することを自動的にできません。仮想マシンの更新には破壊して再作成する必要があり、それが重要なデータを失わせるからです。したがって、このプロセスはユーザに手動でコマンドを入力してもらいます。

PRUNING OLD VERSIONS

古いバージョンを取り除く

Vagrant does not automatically prune old versions because it does not know if they might be in use by other Vagrant environments. Because boxes can be large, you may want to actively prune them once in awhile using vagrant box remove. You can see all the boxes that are installed using vagrant box list.

vagrantは自動的に古いバージョンを取り除きません。他のvagrant環境で使われるかどうかを知らないからです。boxは大きくなるので、あなたは使用しているboxを取り除いて整理するでしょう。"vagrant box list"コマンドを使ってインストールしているboxを全て参照することができます。

終わりに

結局自作のboxの更新方法についてはカバーしませんってばっさり言われてるのでやりたことと違いましたね、利用者目線での使い方でした。

boxから仮想マシンを作成するけど、そのboxを使うのは作成時のみだから、boxをupdateしたからといってその中身の仮想マシンも更新されないから作りなおさなきゃいけないんだよ、ってところがポイントですかね。

自作のboxのバージョニングの仕方はまた改めて調べます。。。

あと英語全然すらすら読めなくて(実際まだ良くわからないところが残ってる)かなり時間かかりました。英語もっと読む機会増やそう。。。