Vagrant + VirtualBox + vagrant-vbguestでCentOSでGuestAdditionsがうまく入らない場合

雑な記事注意。

Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-862.14.4.el7.x86_64
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.  This may take a
 while.

This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    kernel-devel kernel-devel-3.10.0-862.14.4.el7.x86_64
An error occurred during installation of VirtualBox Guest Additions 5.2.22. Some functionality may n
ot work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Redirecting to /bin/systemctl start vboxadd.service
Job for vboxadd.service failed because the control process exited with error code. See "systemctl st
atus vboxadd.service" and "journalctl -xe" for details.

こんな感じのログ出てたら、見るべきは一行目。

[vagrant@localhost ~]$ yum list installed | grep kernel
kernel.x86_64                    3.10.0-862.14.4.el7            @koji-override-1
kernel-headers.x86_64            3.10.0-957.1.3.el7             @updates
kernel-tools.x86_64              3.10.0-862.14.4.el7            @koji-override-1
kernel-tools-libs.x86_64         3.10.0-862.14.4.el7            @koji-override-1

多分こんな感じになってるので、

sudo yum update kernel

https://github.com/dotless-de/vagrant-vbguest/issues/311

確認してないけど、

kernel-devel-`uname -r`

https://github.com/dotless-de/vagrant-vbguest/blob/c0e47b9cb4e8936d270e952668aef78ac2d6e4e8/lib/vagrant-vbguest/installers/redhat.rb#L24

これがよくないのかな。