Michael Stevens
2013-Feb-19 17:49 UTC
[Puppet Users] migrating from cfengine to puppet, node wrangling question
This works, but I''m not sure it''s the best way about going about it. I''m trying to define host groups in my site.pp file in such a way that when puppet runs on my nodes, they "know" their functional role and are configured accordingly. My site.pp; node base { class { ''dirsvc'': } class { ''ntp'': } class { ''yum'': } } # workstations node ''inky.example.com'', ''blinky.example.com'' inherits base { $hostclass = "workstation" class { ''root'': } } # server node ''pinky.example.com'' inherits base { $hostclass = "server" class { ''root'': } } # server node ''clyde.example.com'' inherits base { $hostclass = "server" class { ''root'': } } Example of a manifest using the $hostclass variable; class root { if $hostclass == "server" { $rootpass = ''$6$tTZjKZGj$undthG0kn5.5Fs/'' } else { $rootpass = ''$6$6R8/bcDf$Ta5Uxl7eZlH.MP/'' } user { "root": ensure => present, password => $rootpass, } notify { "my_hostclass": message => "Hostclass: $hostclass", } } -- 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.
Paul Tötterman
2013-Feb-20 08:36 UTC
[Puppet Users] Re: migrating from cfengine to puppet, node wrangling question
Hi Michael This works, but I''m not sure it''s the best way about going about it. I''m> trying to define host groups in my site.pp file in such a way that when > puppet runs on my nodes, they "know" their functional role and are > configured accordingly.May I suggest that you look into using a node classifier (ENC) or at least hiera to separate data from code? I have a module called ''role'' with classes like ''workstation'' and ''compute'' which include other classes. Then I can just assign the class role::workstation or role::compute to a node. Cheers, Paul -- 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.
Felix Frank
2013-Feb-20 12:17 UTC
Re: [Puppet Users] Re: migrating from cfengine to puppet, node wrangling question
On 02/20/2013 09:36 AM, Paul Tötterman wrote:> This works, but I''m not sure it''s the best way about going about it. > I''m trying to define host groups in my site.pp file in such a way > that when puppet runs on my nodes, they "know" their functional role > and are configured accordingly. > > > May I suggest that you look into using a node classifier (ENC) or at > least hiera to separate data from code?More to the point: The funcionality underneath your current pattern (i.e. dynamic variable scoping) is deprecated in puppet 2.7 and (as I understand) is going away in puppet 3. There is good reason for that. It was a manifest design nightmare (where things ceased being as simple as variables declared on node level). Do not use. Cheers, Felix -- 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.
jcbollinger
2013-Feb-20 16:58 UTC
Re: [Puppet Users] Re: migrating from cfengine to puppet, node wrangling question
On Wednesday, February 20, 2013 6:17:29 AM UTC-6, Felix.Frank wrote:> > On 02/20/2013 09:36 AM, Paul T�tterman wrote: > > This works, but I''m not sure it''s the best way about going about it. > > I''m trying to define host groups in my site.pp file in such a way > > that when puppet runs on my nodes, they "know" their functional role > > and are configured accordingly. > > > > > > May I suggest that you look into using a node classifier (ENC) or at > > least hiera to separate data from code? > > More to the point: The funcionality underneath your current pattern > (i.e. dynamic variable scoping) is deprecated in puppet 2.7 and (as I > understand) is going away in puppet 3. >Dynamic variable scoping is indeed gone in Puppet 3, except (as I understand it) for node-scoped variables. That exception was not originally planned, but but the removal of dynamic scoping proved too big a change otherwise. It would have been different, perhaps, if node-scoped variables had qualified names, but they don''t. That doesn''t make reliance on node variables a particularly good idea, however. Externalizing the data is a better solution to the problem, and Hiera is my recommendation for accessing such external data. An ENC is another viable option, but even you''re already using one I''d advise you to consider Hiera for this particular task. 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.