How to set up a time zone with Vagrant, Puppet and Hiera?

I use PuPHPet for my test environments, based on Vagrant / Puppet + Hiera.

In config.yml (Hiera configuration file) I would like to add a section for my time zone

and with the vagrant provision command configure it correctly.

Is it possible?

+3
vagrant puppet hiera puphpet
source share
2 answers

Just add the time zone to any key you want in your hiera file, call it timezone . The value for which you need to set this time zone and the puppet code depends on the system you are shooting at, but I will use the Unix RedHat code.

I recommend setting this value to any valid value that you see in the /usr/share/zoneinfo . As an example, your key might look like this:

timezone: 'US/Pacific'

Then you should use the puppet type file for the symbolic link /etc/localtime for the full /etc/localtime path:

 $tz = hiera('timezone') file {'/etc/localtime': ensure => link, target => "/usr/share/zoneinfo/${tz}"} 
+5
source share

You can install the Time Zone plugin for Vagrant ( vagrant plugin install vagrant-timezone ) and configure the Vagrantfile as follows:

 Vagrant.configure("2") do |config| if Vagrant.has_plugin?("vagrant-timezone") config.timezone.value = "UTC" end # ... other stuff end 

Instead of UTC you can also use :host to synchronize the time zone with the host.

+6
source share

All Articles