LoginSignup
1
1

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-07-13

テスト用に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

で。

あとがき

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

1
1
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
1
1