On Wednesday, April 3, 2013 9:06:58 AM UTC-5, Kubes
wrote:>
> What is the best means to "assign" nodes to a "role"
>
> I have review http://www.craigdunn.org/2012/05/239/ also view a post
> recently with people posting their hirea configs and most of them used a
> role or server_role, etc
>
> In our environment, servers(node) are named by roles, eg:
> web01.prod.domain.com
> db01.prod.domain.com
> etc
>
> Our nodes.pp
>
> node /db\d{2}.(dev|stage|prod).domain.com/ {
> include profile::database_server
> }
>
> Would like to have this as the hiera config:
> :hierarchy:
> - %{environment}/%{module_name}/%{fqdn}
> - %{environment}/%{module_name}/%{role}
> - %{environment}/%{module_name}/common
>
> I see a few options:
>
> 1. Extend out enc to set a global variable "role"
> 2. Assign a node variable "role"
> 3. Custom fact
> 4. other?
>
>
> What is the best practice for handling roles with hiera?
>
> Thanks!
>
I take you to be asking how to communicate the role information embedded in
your nodes'' names to hiera, so as to enable hiera to interpolate it
into
the hierarchy definition. You probably should not use a custom fact
because (i) that cedes control to the node, and (ii) the information is
already being provided by some of the standard facts. Either an
ENC-provided global variable or a node variable should work, but your case
is so simple that I would go with "other".
Specifically, I would at this at the top of your site.pp, outside any node
definition:
$role = regsubst($hostname, ''^([^0-9]+).*$'',
''\1'')
That will extract the initial string of non-digits from the node''s
hostname
and assign it to variable $role. It will do it once for all (so you
don''t
need to do it in each node definition), and it does not rely on an ENC.
John
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.