いまさら感

環境
vagrant 1.8.6
vagrantbox bento/centos-5.11 (virtualbox, 2.3.7)

以下のVagrantfileでマシン立ち上げ

>cat Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-5.11"
  config.vm.hostname = "hostname"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.provision "shell", inline: <<-SHELL
        service network restart
  SHELL
end

vagrant up をしてエラー

>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-5.11'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-5.11' is up to date...
==> default: Setting the name of the VM: work_default_1504162576465_16363
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
GuestAdditions versions on your host (5.1.18) and guest (5.1.22) do not match.
Loaded plugins: fastestmirror
Determining fastest mirrors
Error: Cannot find a valid baseurl for repo: base
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


==> default: Checking for guest additions in VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

yum install -y kernel-devel-`uname -r` gcc make perl bzip2

Stdout from the command:

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:

以下のメッセージ

GuestAdditions versions on your host (5.1.18) and guest (5.1.22) do not match.

GeustAdditionsのバージョンがマッチしていないからアップデートしようとして失敗したよ
対応としては
 →新しいものをインストールしておく
 →アップデートしないようにする
のどちらか

そもそも、GuestAdditionsって何?
GUEST ADDITIONSとは

ゲストマシンにOSを入れた直後では、デスクトップ画面をクリックするとマウスカーソルがゲストOSの中に入ってしまい、右Altキーを押さないとホストOSにカーソルが戻ってきません。
これをマウスキャプチャーと言います。
このままでは使い勝手が悪いので、ホストOSとゲストOS間でマウスカーソルをシームレスに移動させるために、Guest Additionsをインストールします。
Guest Additionsは以下の機能を提供します。
マウスカーソルのシームレスな移動
シームレスなウィンドウサイズの変更
高解像度のデスクトップ画面が使用可能
ゲストマシンの制御と監視
ホストマシンとの時刻の同期
共有フォルダ
クリップボードの共有
オートログオン(Windows,Linux,Solarisのみ)
ハードウェア3Dアクセラレーションのサポート

必要なさそうなので
→アップデートしないようにvagrantfileを書く

>cat Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-5.11"
  config.vm.hostname = "hostname"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vbguest.auto_update = false
  config.vbguest.no_remote = true
  config.vm.provision "shell", inline: <<-SHELL
        service network restart
  SHELL
end

一応GuestAdditionsのバージョンを確認してみる

>vagrant vbguest --status
GuestAdditions versions on your host (5.1.18) and guest (5.1.22) do not match.

upするまえに、マッチしていないようメッセージ出てる

改めて

>vagrant up --provision
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-5.11' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => sharefoleder
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Shutting down interface eth0:
==> default: [
==> default:   OK
==> default: ]
==> default: Shutting down interface eth1:
==> default: [
==> default:   OK
==> default: ]
==> default: Shutting down loopback interface:
==> default: [
==> default:   OK
==> default: ]
==> default: Bringing up loopback interface:
==> default: [
==> default:   OK
==> default: ]
==> default: Bringing up interface eth0:
==> default: Determining IP information for eth0...
==> default:  done.
==> default: [
==> default:   OK
==> default: ]
==> default: Bringing up interface eth1:
==> default: [
==> default:   OK
==> default: ]

状態確認

>vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

オッケー