Atlas TutorialでPackerを用いてAtlas上でBOXをbuildし、
Vagrant upまでを疎通確認します
手順
サインイン
Atlasにサインインします。
Tutorialのメニュー選択
Build Vagrant Boxes with Packer and Atlasを選択します
Install Packer
Packerのバージョンを確認します。
$ packer version
Clone Packer Template
Packerのテンプレートをcloneします
$ git clone "https://github.com/hashicorp/atlas-packer-vagrant-tutorial.git"
Generate Token
APIトークンを生成します。
set environment
$ export ATLAS_TOKEN="your token"
Verify
$ curl "https://atlas.hashicorp.com/ui/tutorial/check?access_token=$ATLAS_TOKEN"
Configure build settings in Atlas
build名を指定します。今回は以下の名前にしました。
atlas_sample
Packer Push
だいたい30分かかります。 また、たまにbuildが失敗するので、その場合は再実行します。
$ packer push -name tbpgr/atlas_sample template.json
完成したBOXをVagrantから利用
Vagrantfileの生成
$ vagrant init tbpgr/atrals_sample -m
Vagrantfile
config.vm.provider
の部分は手動で追加しました
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "tbpgr/atrals_sample" config.vm.network :private_network, ip: "172.16.33.109" config.vm.provider :virtualbox do |vb| vb.name = "atlas_sample" end end
Vagrant 起動
$ vagrant login --check You aren't logged in! Run `vagrant login` to log in $ vagrant login --token $ATLAS_TOKEN The token was successfully saved. You are already logged in. $ vagrant login --check You are already logged in. $ vagrant up --provider virtualbox $ vagrant ssh Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-32-generic x86_64) * Documentation: https://help.ubuntu.com/ New release '14.04.3 LTS' available. Run 'do-release-upgrade' to upgrade to it.
図でまとめ