The vboxadd-service
in my VirtualBox guests has to be running to obtain an ip from the following VagrantFile
code snippet, or else the vagrant hostupdater
command won't work as expected:
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
if vm.id
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/2/V4/IP"`.split()[1]
end
end
Resulting /etc/hosts
file when vboxadd-service
is turned off:
## vagrant-hostmanager-start
value bareOSdirector
value webserver
value bareOSremoteSD
## vagrant-hostmanager-end
And this is because...
If the vboxadd-service
is running...you can run this command and get:
VBoxManage guestproperty get "turnkey_lamp_packer_test_webserver_1502906374188_41719" "/VirtualBox/GuestInfo/Net/2/V4/IP"
Value: 10.0.3.8
But if it is not running instead you'll get:
VBoxManage guestproperty get "turnkey_lamp_packer_test_webserver_1502906374188_41719" "/VirtualBox/GuestInfo/Net/2/V4/IP"
No value set!
But in order for me to be able to easily change the time across my VMs for testing things out...the vboxadd-service
has to NOT be running on a guest vm, or else the time will sync with the host machine when I change it using the sudo date -s
command.
How can one keep the vboxadd-service
running while ignoring the time sync, apart from starting and stopping the service every time? Is there a way to keep the service running without syncing the time with the host?
This appears to work:
# On the host...
VBoxManage setextradata "vm-name" "/VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
# On the guest(s)...
sudo sed -i.bak 's/\(daemon \$binary\) \(--pidfile \$PIDFILE > \/dev\/null\)/\1 --disable-timesync \2/g' /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service && rm /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service.bak
sudo sed -i.bak '0,/start-stop-daemon --start --exec \$1 -- \$2 \$3/{s/start-stop-daemon --start --exec \$1 -- \$2 \$3/\0 $4/}' /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service && rm /opt/VBoxGuestAdditions-5.0.40/init/vboxadd-service.bak
sudo systemctl daemon-reload
sudo systemctl restart vboxadd-service
sudo rm /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service