JeremyCampbell
2013-Aug-21 17:20 UTC
[Puppet Users] Assigning a dynamic role to be used by hiera
I need to define data for roles so I add the ''role'' dynamic data source. - "%{::environment}/%{::clientcert}" - "%{::clientcert}" - "%{::environment} - "%{::role}" - common Our site.pp uses a hostname regex to classify nodes into roles e.g. node /^ns\d+$/ { include role::nameserver } Can we add the $role variable to the role class and hiera will use it? e.g. class role::nameserver { $role = ''nameserver'' include base include bind include shorewall } Would this work? Is there a better pattern that doesn''t involve having to define custom facts on the servers? -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Chad Huneycutt
2013-Aug-21 19:58 UTC
Re: [Puppet Users] Assigning a dynamic role to be used by hiera
Yes, that will work. We actually do something slightly ickier, so the data all stays in hiera: hiera hierarchy: - nodes/%{hostname} - ... - roles/%{role} nodes/foo.yaml: ... role: desktop classes: - "roles::%{role}" node default { $role = hiera(''role'') include hiera(''classes'') } - Chad On Wed, Aug 21, 2013 at 1:20 PM, JeremyCampbell <jeremycampbell87@gmail.com> wrote:> > I need to define data for roles so I add the ''role'' dynamic data source. > > - "%{::environment}/%{::clientcert}" > - "%{::clientcert}" > - "%{::environment} > - "%{::role}" > - common > > Our site.pp uses a hostname regex to classify nodes into roles e.g. > > node /^ns\d+$/ { > include role::nameserver > } > > Can we add the $role variable to the role class and hiera will use it? e.g. > > class role::nameserver { > $role = ''nameserver'' > include base > include bind > include shorewall > } > > Would this work? Is there a better pattern that doesn''t involve having to > define custom facts on the servers? > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out.-- Chad M. Huneycutt -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Ellison Marks
2013-Aug-21 22:29 UTC
[Puppet Users] Re: Assigning a dynamic role to be used by hiera
you might want to explicitly top-scope role, ie. $::role = ''nameserver'' Not sure if that will matter in this case, but I don''t think it can hurt. As an aside, we set our role variable with facter.d on the nodes themselves, as we don''t have hostnames that easily work out to roles. On Wednesday, August 21, 2013 10:20:56 AM UTC-7, JeremyCampbell wrote:> > > I need to define data for roles so I add the ''role'' dynamic data source. > > - "%{::environment}/%{::clientcert}" > - "%{::clientcert}" > - "%{::environment} > - "%{::role}" > - common > > Our site.pp uses a hostname regex to classify nodes into roles e.g. > > node /^ns\d+$/ { > include role::nameserver > } > > Can we add the $role variable to the role class and hiera will use it? > e.g. > > class role::nameserver { > $role = ''nameserver'' > include base > include bind > include shorewall > } > > Would this work? Is there a better pattern that doesn''t involve having to > define custom facts on the servers? >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.