How to config timezone with Vagrant, Puppet and Hiera?

蓝咒 提交于 2019-12-05 20:52:50

Just add your timezone to whatever key you want in your hiera file, let's call it timezone. The value for which and the puppet code you'd need to set that timezone depends on the system you're firing up, but I'll assume RedHat flavor of unix.

I recommend setting that to any valid value you'd see under /usr/share/zoneinfo. As an example your key may look like:

timezone: 'US/Pacific'

Then you'd use the file puppet type to symlink /etc/localtime to the full path of the timezone:

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

You can install Time Zone plugin for Vagrant (vagrant plugin install vagrant-timezone) and configure Vagrantfile in the following way:

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 timezone with the host.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!