On 10 Aug 2015, at 09:54, Eddie Mashayev <eddie...@gmail.com> wrote:

> Hi Martin, 
> 
> Thanks for the help. I used the second approach. 
> 
> 1) I’ve created custom fact to identify the server location (I’m using the 
> timezone fact) – Now I’m able to identify all my servers by location. 
> 2) I’m not sure about the second part “put ntp::servers into the appropriate 
> hiera data hierarchy” – I’m using Foreman and NOT Puppet enterprise if it 
> matters. Can you elaborate more how to implement it right, maybe add some 
> code if possible.

Hiera is not related to Puppet Enterprise.
Hiera is a data backend for automatic parameter lookups.
see http://docs.puppetlabs.com/hiera/latest/

You need to create a hiera.yaml config file.
The config file may look like this:

:backends:
  - yaml
:yaml:
  :datadir: ‘/etc/puppet/data’
:hierachy:
  - “nodes/#{::certname}”
  - “location/#{::timezone}”
  - global

In your hiera data directory you can provide yaml files for hierarchies (you 
don’t have to, but you can!)

/etc/puppet/data/
  - nodes/foo.bar.domain.com.yaml # has host specific parameters
  - location/CEST.yaml # has parameters for CEST timezone
  - location/PDT.yaml    # has parameters for PDT timezone systems
  - global.yaml  # has global parameters

Hiera parses the data hierarchy and uses the first match.
To allow dynamic data lookup the variable names from the module have to be 
prefixed with the class name where they are used.
Note: this only works with parameterised classes, not with normal variables 
inside a manifest.

With foreman you should also be able to create a group setting based on 
timezone fact (I don’t have access to foreman right now, so I can not verify).

Best,
Martin

> 
> Thanks,
> EddieM
> 
> On Sunday, August 9, 2015 at 5:35:07 PM UTC+3, Martin Alfke wrote:
> Hi Eddie, 
> 
> On 09 Aug 2015, at 16:25, Eddie Mashayev <eddi...@gmail.com> wrote: 
> 
> > Hi All, 
> > 
> > I have many servers spread in 3 different time zones USA (NY and San 
> > Francisco) and also in ISR. Have 3 NTP servers, one NTP server in each 
> > location. 
> > https://forge.puppetlabs.com/puppetlabs/ntp module is letting you to insert 
> > an array of NTP servers 
> > 
> > class { '::ntp': 
> > servers => [ 'ntp1.corp.com', 'ntp2.corp.com' ], 
> > } 
> > 
> > I can override this array but the problem is how to fit the correct NTP 
> > server to each server in the different location. 
> > In other words, how can I modified the puppet module to fit server to the 
> > correct NTP Server by locations. 
> > 
> > For example - I thought using the server prefix name to choose the right 
> > NTP server, for example if this server is located in NY so it prefix name 
> > is ny-{server name} so I can fit it to NY NTP server but it look like a 
> > headache to do it. 
> > 
> > Do you have any idea how can it be done in most efficient way with the NTP 
> > module provided by puppetlabs. 
> 
> Several solutions: 
> 
> 1. write wrapper module per data center: 
> 
> class ny_ntp { 
>   class { ‘::ntp’: 
>     server => [‘ny_ntp.corp.com’], 
>   } 
> } 
> 
> class sf_ntp { 
>   class { ‘::ntp’: 
>     servers => [‘sf_ntp.corp.com’], 
>   } 
> } 
> 
> class isr_ntp { 
>   class { ‘::ntp’: 
>    servers => [‘isr_ntp.corp.com’], 
>   } 
> } 
> 
> use one of the the wrapper class within node classification 
> 
> 2. use hiera 
> 
> provide a custom fact to identify location per server and put ntp::servers 
> into the appropriate hiera data hierarchy. 
> 
> Best, 
> Martin 
> 
> 
> > 
> > 
> > Thanks, 
> > EddieM 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Puppet Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to puppet-users...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/puppet-users/8cdf1ae0-46c8-4de6-bb06-9f42bdbd31ed%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/d/optout. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/d7398ad5-9b31-42e5-b3ee-d1eb889a8356%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/DD001BB3-D530-4509-AFDE-051381F58E29%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to