Help us understand the problem. What is going on with this article?

vangrantでcentos5(bento/centos-5.11)環境を作る

More than 1 year has passed since last update.

テスト用にcentos5.11環境を作ろうとしたら
ちょっとハマったのでメモ&共有を。

やったこと

・boxを追加してinit

vagrant box add bento/centos-5.11
vagrant init bento/centos-5.11

・Vagrantfileを編集したのち、起動

vagrant up

すると、以下のエラーが発生した。

Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt


Stderr from the command:

Error: Cannot find a valid baseurl for repo: base

つまり

vagrant up で yum が走るが、centos5 の yum リポジトリがもう存在してないので、エラーとなって止まっている。
CentOS-Base.repo を編集して、yum の向き先を vault.centos.org へ変更しなくてはならない。
参考

なるほど。

…。

あれ?

vagrant up できないのに、どうやって CentOS-Base.repo 書き換えるの…?

provisioningを使う

Provisioningを使うと、仮想マシンが立ち上がったあとの処理を記述できます。
参考

なので、修正済みの CentOS511-Base.repo を用意し、それを vagrant内の /etc/yum.repos.d/CentOS-Base.repo に上書きします。

Vagrantfile
   config.vm.provision "file", source: "CentOS511-Base.repo", destination: "/home/vagrant/CentOS-Base.repo"
   config.vm.provision "shell", inline: <<-SHELL
     sudo cp /home/vagrant/CentOS-Base.repo /etc/yum.repos.d/.
   SHELL

あとは

vagrant reload --provision

で。

あとがき

「こうすればよかったんじゃないの?」とか
あれば是非教えて下さるとうれしいです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away