I was playing with my Linux vagrant boxes lately and I realized I was always spinning third party boxes that had a totally different time zone (Europe/UK mostly). Up until now I never bothered as I have used bunch of those from vagrant Cloud for years. I sometimes notice, and think of using a shell command to fix it during the bootstrap, but it I haven’t had the time. However, I was heavily debugging some logs this week and the wrong Time Zone started to get annoying for me so I decided to look for a permanent fix.
I. Vagrant Time zone plugin to the rescue
- How does it work
Install the plugin:
C:\Users\brokedba> vagrant plugin install vagrant-timezone
Installing the 'vagrant-timezone' plugin. This can take a few minutes...
Installed the plugin 'vagrant-timezone (1.3.0)'!
To Configure time zone for all Vagrant VMs, add the following to $HOME/.vagrant.d/Vagrantfile or to a project specific Vagrantfile (see below example in windows)
--- Add the IF block below in the master or each build’s Vagrantfile
Vagrant.configure("2") do |config| if Vagrant.has_plugin?("vagrant-timezone") config.timezone.value = "America/Toronto" end # ... other stuff end
You can of course choose your own Time Zone from this TZ database list
- The configuration is done on
Note that no services are restarted automatically so they may keep using the old time zone information.
- This plugin requires Vagrant 1.2 or newer.
II. Usage and prerequisites
- Linux guests.
- Debian (and derivatives)
- RedHat (and derivatives)
- OS X
This will hopefully encourage you to more often use and enjoy vagrant boxes without being stuck with the original time zone .
Thanks for reading