Time-Zone through puppet

[root@server ~]# puppet module search timezone
Notice: Searching https://forgeapi.puppetlabs.com
NAME DESCRIPTION AUTHOR KEYWORDS
bashtoni-timezone Configure /etc/localtime and associated system files @bashtoni linux timezone
attachmentgenie-timezone Puppet timezone Module @attachmentgenie localtime tzdata timezone
example42-timezone Puppet module to manage timezones @example42 timezone time example42
ghoneycutt-timezone Manage system time zone @ghoneycutt
saz-timezone UNKNOWN @saz centos debian ubuntu timezone
kickstandproject-timezone UNKNOWN @kickstandproject ubuntu timezone
rlenglet-timezone System timezone configuration @rlenglet debian ubuntu timezone tzdata
aageyev-timezone Configure timezone on ubuntu @aageyev timezone ubuntu
a2labs-timezone Ubuntu timezone configuration @a2labs
mtulio-linux Manage main Linux configurations in a single module. @mtulio users timezone motd hosts tools
mikegleasonjr-server The Server module serves as a base configuration for all your… @mikegleasonjr swap rsyslog ntp timezone

————————————————————————————
[root@server ~]# puppet module install bashtoni-timezone
Notice: Preparing to install into /etc/puppet/modules …
Notice: Downloading from https://forgeapi.puppetlabs.com
Notice: Installing — do not interrupt …
/etc/puppet/modules
└── bashtoni-timezone (v1.0.0)

[root@server ~]# puppet module list
/etc/puppet/modules
├── bashtoni-timezone (v1.0.0)
—————————————————————————————–
[root@server ~]# gem install hiera-puppet
Successfully installed json_pure-1.8.3
Successfully installed hiera-1.3.4
Successfully installed hiera-puppet-1.0.0
3 gems installed
Installing ri documentation for json_pure-1.8.3…
Installing ri documentation for hiera-1.3.4…
Installing ri documentation for hiera-puppet-1.0.0…
Installing RDoc documentation for json_pure-1.8.3…
Installing RDoc documentation for hiera-1.3.4…
Installing RDoc documentation for hiera-puppet-1.0.0…

[root@server ~]# hiera –version
1.3.4

[root@server ~]# rpm -qa hiera*
hiera-1.3.4-1.el6.noarch
—————————————————————————————–
[root@server ~]# cat /etc/hiera.yaml

:backends:
– yaml
:hierarchy:
– defaults
– “%{clientcert}”
– “%{environment}”
– global

:yaml:
# datadir is empty here, so hiera uses its defaults:
# – /var/lib/hiera on *nix
# – %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
:datadir:
——————————————————————————————
[root@server ~]# cat /etc/hiera.yaml

:backends:
– yaml
:hierarchy:
– defaults
– “%{clientcert}”
– “%{environment}”
– global

:yaml:
# datadir is empty here, so hiera uses its defaults:
# – /var/lib/hiera on *nix
# – %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
:datadir: /etc/puppet/hieradata
—————————————————————————————-
[root@server ~]# mkdir /etc/puppet/hieradata
[root@server ~]# touch /etc/puppet/hieradata/common.yaml
[root@server ~]# cat >> /etc/puppet/manifests/site.pp
hiera_include(“classes”)
————————————————————————————–
[root@server ~]# cat /etc/puppet/hieradata/common.yaml

classes:
– ‘timezone’
timezone::region: ‘America’
timezone::locality: ‘New_York’
———————————————————————————-
[root@server ~]# cat /var/lib/hiera/common.yaml

classes:
– ‘timezone’
timezone::region: ‘America’
timezone::locality: ‘New_York’
———————————————————————————-
[root@client ~]# date
Sun Jun 12 16:03:44 IST 2016
[root@client ~]# cat /etc/localtime
LMTHMTBURTISTR�[hMX [h HMTBURTISTTZif2����V��(�����ۆ������q����̕2������t�R�R�[MX
IST-5:30

[root@client ~]#cat /etc/sysconfig/clock
# The time zone of the system is defined by the contents of /etc/localtime.
# This file is only for evaluation by system-config-date, do not rely on its
# contents elsewhere.
ZONE=”Asia/Kolkata”
———————————————————————————-
[root@client ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item classes in any Hiera data file and no default supplied at /etc/puppet/manifests/site.pp:2 on node client.puppet.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
———————————————————————————-
[root@server ~]# hiera classes ::environment=dev environment=dev –debug
DEBUG: Sun Jun 12 18:24:45 +0530 2016: Hiera YAML backend starting
DEBUG: Sun Jun 12 18:24:45 +0530 2016: Looking up classes in YAML backend
DEBUG: Sun Jun 12 18:24:45 +0530 2016: Looking for data source common
DEBUG: Sun Jun 12 18:24:45 +0530 2016: Cannot find datafile /var/lib/hiera/common.yaml, skipping
nil

[root@server hiera]# ln /etc/puppet/hieradata/common.yaml /var/lib/hiera/common.yaml

 

[root@server hiera]# hiera classes ::environment=dev environment=dev –debug
DEBUG: Sun Jun 12 18:26:19 +0530 2016: Hiera YAML backend starting
DEBUG: Sun Jun 12 18:26:19 +0530 2016: Looking up classes in YAML backend
DEBUG: Sun Jun 12 18:26:19 +0530 2016: Looking for data source common
DEBUG: Sun Jun 12 18:26:19 +0530 2016: Found classes in common
[“timezone”]

————————————————————————————-
[root@client ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for client.puppet.com
Info: Applying configuration version ‘1465731462’
Notice: /Stage[main]/Timezone/File[/etc/sysconfig/clock]/content:
— /etc/sysconfig/clock 2016-06-01 16:49:41.585000001 +0530
+++ /tmp/puppet-file20160612-3222-12u9pcg-0 2016-06-12 18:26:39.765000034 +0530
@@ -1,4 +1,2 @@
-# The time zone of the system is defined by the contents of /etc/localtime.
-# This file is only for evaluation by system-config-date, do not rely on its
-# contents elsewhere.
-ZONE=”Asia/Kolkata”
+ZONE=”America/New_York”
+UTC=true

Info: Computing checksum on file /etc/sysconfig/clock
Info: /Stage[main]/Timezone/File[/etc/sysconfig/clock]: Filebucketed /etc/sysconfig/clock to puppet with sum 357ec983f67a2b384f87a86e0ee5603d
Notice: /Stage[main]/Timezone/File[/etc/sysconfig/clock]/content: content changed ‘{md5}357ec983f67a2b384f87a86e0ee5603d’ to ‘{md5}0a26b7c2248ec01bfe7f75595eaa1cab’
Notice: /Stage[main]/Timezone/File[/etc/localtime]/content:
Binary files /etc/localtime and /tmp/puppet-file20160612-3222-1gujhfp-0 differ

Info: Computing checksum on file /etc/localtime
Info: /Stage[main]/Timezone/File[/etc/localtime]: Filebucketed /etc/localtime to puppet with sum 48e679db395e606fa97d134fe1bf82ee
Notice: /Stage[main]/Timezone/File[/etc/localtime]/content: content changed ‘{md5}48e679db395e606fa97d134fe1bf82ee’ to ‘{md5}e4ca381035a34b7a852184cc0dd89baa’
Notice: Finished catalog run in 0.52 seconds
——————————————————————————
[root@client ~]# date
Sun Jun 12 08:58:25 EDT 2016

[root@client ~]# cat /etc/sysconfig/clock
ZONE=”America/New_York”
UTC=true
——————————————————————–

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s