CentOS7 の Vagrant 仮想マシン (vagrant box) 用 packer template を作成しました

ちょっと出遅れた感はありますが、CentOS7 の vagrant box 用 packer template を作成しました。
新しい OS の packer template は、以下の感じで作成すればいいと思います。

  • packer, vagrant, virtualbox は最新版にバージョンアップする*1
  • まずは手動で OS インストールして、/root/anaconda-ks.cfg で kickstart の設定を確認する
  • あとはひたすら packer build で try and error

template は GitHub にあげました。
packer/centos at master · kjitsukata/packer · GitHub

ちょっとハマったところ

packer build 時に Guest Additions module のビルドに失敗して、/vagrant がマウントできませんでした。

(packer build 時のエラー)

virtualbox-iso: Building the main Guest Additions modules [FAILED]

(vagrant up 時のエラー)

==> default: Mounting shared folders...
    default: /vagrant => /Users/hogehoge/vagrant
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant

virtualbox 4.3.12 を使っていたのですが、不具合に当たったようです。

新しい OS で vagrant box を作る時は、packer, vagrant, virtualbox を最新版にした方がいいですね!

*1:バージョンが古いと、VBoxGuestAdditions のインストールとかでハマる場合があります。今回もハマりました。