andreash
2010-May-21 23:32 UTC
[Puppet Users] getting started with puppet: overriding roles
hi there, i''m not sure as to how to call the subject of this post, as i''m totally new to puppet -- so please forgive me if this is misleading ... for my servers, i''m planning to do something like this (pseudo-code): class (?) base-config: include ntp::client include resolver ... all servers should by default include the base-config class. however, for the node which has the role "ntpd-server", i don''t want ntp::client to be included, but rather ntp::server. how can i do this? my ntp module looks like this: class ntp { package { ''openntpd'': ensure => latest } service { ''openntpd'': ensure => running, } $ntpserverip = ''192.168.1.1'' # this is somehow to be replaced with the # actual ip of the ntpd server class client { $role = ''CLIENT'' } class server { $role = ''SERVER'' } file { "/etc/openntpd/ntpd.conf": template("ntp/ntpd.conf.erb") } } and the template looks like this: <% if role == "SERVER" %> listen on <%= ntpserverip %> server ptbtime1.ptb.de server ptbtime2.ptb.de server ptbtime3.ptb.de <% end %> <% if role == "CLIENT" %> server <%= ntpserverip %> <% end %> to summarize: question 1: how can i make sure that the server which shall be openntpd server has $role = ''SERVER'' and all others have role ''CLIENT'' ? question 2: how can i include the ip of the ntp server as $ntpserverip without having to manually set it? question 3: what else did i do wrong? i just found out about puppet, and am really excited about it. looks like a great helper even for a rather small (~15 machines (virtual + physical) in total) environment. thanks for your insight! Andreas. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2010-May-22 02:54 UTC
Re: [Puppet Users] getting started with puppet: overriding roles
andreash <hilboll@gmail.com> writes:> i''m not sure as to how to call the subject of this post, as i''m totally new > to puppet -- so please forgive me if this is misleading ... > > for my servers, i''m planning to do something like this (pseudo-code): > > class (?) base-config: > include ntp::client > include resolver > ... > > all servers should by default include the base-config class.I would suggest, instead, this: define base ($ntp, ...) { case $ntp { ''master'': { include ntp::master } ... default: { fail("sorry, ntp $ntp is an unknown value") } } } [...]> question 1: how can i make sure that the server which shall be > openntpd server has $role = ''SERVER'' and all others have role > ''CLIENT'' ?Essentially, use ''fail'' when it isn''t set. You can pull this up a bit by, for example, using the define there without a default value, but it essentially comes down to the same thing.> question 2: how can i include the ip of the ntp server as $ntpserverip > without having to manually set it?You can''t. At least, not trivially: puppet doesn''t let you ask questions like "what is the IP address of the server(s) including the ntp::master class". Your choices come down to writing it in the manifest somewhere, or using a fact or external tool that works it out for you.> question 3: what else did i do wrong?Nothing I can see; when *I* started this I used node inheritance, which is a mistake, because it is useless. Your approach isn''t. :) Daniel -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Silviu Paragina
2010-May-25 00:32 UTC
Re: [Puppet Users] getting started with puppet: overriding roles
On 22.05.2010 02:32, andreash wrote:> hi there, > > i''m not sure as to how to call the subject of this post, as i''m > totally new to puppet -- so please forgive me if this is > misleading ... > > for my servers, i''m planning to do something like this (pseudo-code): > > class (?) base-config: > include ntp::client > include resolver > ... > > all servers should by default include the base-config class. > > however, for the node which has the role "ntpd-server", i don''t want > ntp::client to be included, but rather ntp::server. > > how can i do this? > > my ntp module looks like this: > > class ntp { > package { ''openntpd'': > ensure => latest > } > > service { ''openntpd'': > ensure => running, > } > $ntpserverip = ''192.168.1.1'' # this is somehow to be replaced with > the > # actual ip of the ntpd server >You may have some success of setting this ip address automatically with exported resources. You export the resources in the server class, and you realize them on the client. Check out http://docs.puppetlabs.com/guides/exported_resources.html . Till now I haven''t seen this used to set up ntp, but I think it might be possible with the help of the concat module. Silviu -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan Bode
2010-May-25 00:39 UTC
Re: [Puppet Users] getting started with puppet: overriding roles
On Fri, May 21, 2010 at 4:32 PM, andreash <hilboll@gmail.com> wrote:> hi there, > > i''m not sure as to how to call the subject of this post, as i''m > totally new to puppet -- so please forgive me if this is > misleading ... > > for my servers, i''m planning to do something like this (pseudo-code): > > class (?) base-config: > include ntp::client > include resolver > ... > > all servers should by default include the base-config class. > > however, for the node which has the role "ntpd-server", i don''t want > ntp::client to be included, but rather ntp::server. > > how can i do this? >you can include both a parent and child class in puppet and puppet is smart enough to apply all of the overridden attributes. I use this fact sometimes in combination with an external node classifier (like the dashboard) to override resources from parent groups. I also opened a feature on the Dashboard to better support this kind of behavior. http://projects.puppetlabs.com/issues/3675> my ntp module looks like this: > > class ntp { > package { ''openntpd'': > ensure => latest > } > > service { ''openntpd'': > ensure => running, > } > $ntpserverip = ''192.168.1.1'' # this is somehow to be replaced with > the > # actual ip of the ntpd server > class client { > $role = ''CLIENT'' > } > class server { > $role = ''SERVER'' > } > file { "/etc/openntpd/ntpd.conf": > template("ntp/ntpd.conf.erb") > } > } > > and the template looks like this: > > <% if role == "SERVER" %> > listen on <%= ntpserverip %> > server ptbtime1.ptb.de > server ptbtime2.ptb.de > server ptbtime3.ptb.de > <% end %> > > <% if role == "CLIENT" %> > server <%= ntpserverip %> > <% end %> > > to summarize: > > question 1: how can i make sure that the server which shall be > openntpd server has $role = ''SERVER'' and all others have role > ''CLIENT'' ? > > question 2: how can i include the ip of the ntp server as $ntpserverip > without having to manually set it? > > question 3: what else did i do wrong? > > i just found out about puppet, and am really excited about it. looks > like a great helper even for a rather small (~15 machines (virtual + > physical) in total) environment. > > thanks for your insight! > > Andreas. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.