LoginSignup
20
14

More than 5 years have passed since last update.

Vagrant Atlasがいつの間にか無くなってたので移行した

Last updated at Posted at 2018-05-07

何が起こったか

久々にローカルのVMインスタンスを作ろうとしたら、これまで使えていたBoxが軒並みcould not be foundに……
これまでBoxを提供していたVagrant Atlasサービスは、Vagrant Cloudというものに移行する(した)ようです。

Vagrant Cloud Migration Announcement
https://www.hashicorp.com/blog/vagrant-cloud-migration-announcement

updateを利用者に通知できるようになったり、いろいろと機能強化がなされたようです。

必要なBoxは下記URLから検索できるようになったようです。
https://app.vagrantup.com/boxes/search

なお、以降の動作確認はVagrant 1.9.1で行いました。

$ vagrant --version
Vagrant 1.9.1

エラーの具体例

下記のようなエラーが出力される場合は、既にAtlas上にBoxイメージが無い可能性が高いです。
「以前はこの設定で出来たんだけどな…」という場合はほぼこれです。

エラーメッセージ

$ vagrant up
Bringing machine 'stdsv1' up with 'virtualbox' provider...
==> stdsv1: Box 'centos/7' could not be found. Attempting to find and install...
    stdsv1: Box Provider: virtualbox
    stdsv1: Box Version: 1803.01
The box 'centos/7' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://atlas.hashicorp.com/centos/7"]
Error: The requested URL returned error: 404 Not Found

Vagrantfile(修正前)

下記のVagrantファイルを元にvagrant upを行うと、上記エラーが出ます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "centos/7"
  config.vm.box_version = "1803.01"
  config.vm.boot_timeout = 600
  config.vm.provision :shell, :path => "bootstrap.sh"

  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
    v.cpus = 1
  end

  config.vm.network "forwarded_port", guest:22, host:2322
  config.vm.define :stdsv1 do |c1|
    c1.vm.hostname = "stdsv1"
    c1.vm.network :private_network, ip: "192.168.255.11"
  end
end

Vagrantfile(修正後)

「config.vm.box_url」を指定することで、Vagrant Cloud上のファイルを取得することができるようになります。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "centos/7"
  config.vm.box_url = "https://app.vagrantup.com/centos/boxes/7"  # ←この行を追加
  config.vm.box_version = "1803.01"
  config.vm.boot_timeout = 600
  config.vm.provision :shell, :path => "bootstrap.sh"

  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
    v.cpus = 1
  end

  config.vm.network "forwarded_port", guest:22, host:2322
  config.vm.define :stdsv1 do |c1|
    c1.vm.hostname = "stdsv1"
    c1.vm.network :private_network, ip: "192.168.255.11"
  end
end
20
14
2

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
20
14