I just started messing with puppet, and i love it! I have used cfengine in the past, and were in process of planing to replace cfengine now. One thing thats stumped me this weekend and i know i read your working on virtal defines so i can''t do that, but how can i get arond this issue with the curretn setup. I think i am missing something fundamentally simple here. i have this definition which is much longer but ill cut it out to the relevant portion: define syslog_ng($source) { file { syslog: path => "/etc/syslog-ng/syslog-ng.conf", owner => "root", group => "root", mode => 440, backup => main, source => $source, notify => Service[syslog-ng] } } then i define 2 classes: class syslog_server { syslog_ng { "server": source =>"puppet://puppet/dist/apps/ syslog-ng/syslog-server.conf" } } class syslog_client{ syslog_ng { "client": source => "puppet://puppet/dist/apps/ syslog-ng/syslog-client.conf" } } My problem is that i Want the syslog_client to be in the default host group, but i want to override it for the syslog servers (2 nodes). Am i just looking at this wrong ? (my gut says yes, but i could use a bit of help). thanks in advance, and thanks for making puppet! - Jesse
On 2007.06.04 13:55:14 +0000, Jesse Nelson wrote:> I just started messing with puppet, and i love it! I have used > cfengine in the past, and were in process of planing to replace > cfengine now. > > One thing thats stumped me this weekend and i know i read your > working on virtal defines so i can''t do that, but how can i get arond > this issue with the curretn setup. I think i am missing something > fundamentally simple here. > > i have this definition which is much longer but ill cut it out to the > relevant portion: > > define syslog_ng($source) { > file { syslog: > path => "/etc/syslog-ng/syslog-ng.conf", > owner => "root", > group => "root", > mode => 440, > backup => main, > source => $source, > notify => Service[syslog-ng] > } > } > > then i define 2 classes: > > class syslog_server { > syslog_ng { "server": source =>"puppet://puppet/dist/apps/ > syslog-ng/syslog-server.conf" } > } > > class syslog_client{ > syslog_ng { "client": source => "puppet://puppet/dist/apps/ > syslog-ng/syslog-client.conf" } > } > > My problem is that i Want the syslog_client to be in the default host > group, but i want to override it for the syslog servers (2 nodes). Am > i just looking at this wrong ? (my gut says yes, but i could use a > bit of help).There''s more than a couple of ways to do this. The two I use most commonly are variables and class inheritance. For this example, I would normally use class inheritance. I would probably not use a definition for this. e.g. A variable node ''imasyslog_server.com'' { $syslog_type = "server" include syslog } node ''imasyslog_client.com'' { include syslog } class syslog { file { syslog_conf: path => "/etc/syslog-ng/syslog-ng.conf", owner => "root", group => "root", mode => 440, backup => main, source => $syslog ? { "server" => "puppet://puppet/dist/apps/syslog-ng/syslog-server.conf", default => "puppet://puppet/dist/apps/syslog-ng/syslog-client.conf", }, notify => Service[syslog-ng] } } e.g. Class inheritance node ''imasyslog_server.com'' { include syslog_server } node ''imasyslog_client.com'' { include syslog } class syslog { file { syslog_conf: path => "/etc/syslog-ng/syslog-ng.conf", owner => "root", group => "root", mode => 440, backup => main, source => "puppet://puppet/dist/apps/syslog-ng/syslog-client.conf", notify => Service[syslog-ng] } } class syslog_server inherits syslog { File["syslog_conf"] { source => "puppet://puppet/dist/apps/syslog-ng/syslog-server.conf", } } HTH, --Robert
thanks my initial hack was to just use a conditional source based on $hostname but that is not a very robust way of doing it. I tried to use a veriable, but for some reason it wouldn''t work. I think its scope ? not sure tho i inherit the base template for all hosts even on a syslog server. i tried it like this node base { include syslog_ng } node default inherits base {} node syslogserver inherits base { $syslog_type = server } class syslog_ng { file { syslog_conf: path => "/etc/syslog-ng/syslog-ng.conf", owner => "root", group => "root", mode => 440, source => $syslog_type ? { server => "puppet://puppet/dist/apps/syslog-ng/syslog-server.conf", default => "puppet://puppet/dist/apps/syslog-ng/ syslog-server.conf" } notify => Service[syslog-ng] } guess i would have to then include the syslog_ng class again here ? even tho base is also including it ? I used class inheritance and got it working fine. I am just trying to understand how things are working a bit better. On Jun 5, 2007, at 7:22 AM, Robert Nickel wrote:> On 2007.06.04 13:55:14 +0000, Jesse Nelson wrote: > > I just started messing with puppet, and i love it! I have used > > cfengine in the past, and were in process of planing to replace > > cfengine now. > > > > One thing thats stumped me this weekend and i know i read your > > working on virtal defines so i can''t do that, but how can i get > arond > > this issue with the curretn setup. I think i am missing something > > fundamentally simple here. > > > > i have this definition which is much longer but ill cut it out to > the > > relevant portion: > > > > define syslog_ng($source) { > > file { syslog: > > path => "/etc/syslog-ng/syslog-ng.conf", > > owner => "root", > > group => "root", > > mode => 440, > > backup => main, > > source => $source, > > notify => Service[syslog-ng] > > } > > } > > > > then i define 2 classes: > > > > class syslog_server { > > syslog_ng { "server": source =>"puppet://puppet/dist/apps/ > > syslog-ng/syslog-server.conf" } > > } > > > > class syslog_client{ > > syslog_ng { "client": source => "puppet://puppet/dist/apps/ > > syslog-ng/syslog-client.conf" } > > } > > > > My problem is that i Want the syslog_client to be in the default > host > > group, but i want to override it for the syslog servers (2 > nodes). Am > > i just looking at this wrong ? (my gut says yes, but i could use a > > bit of help). > > There''s more than a couple of ways to do this. The two I use most > commonly > are variables and class inheritance. For this example, I would > normally use > class inheritance. I would probably not use a definition for this. > > e.g. A variable > > node ''imasyslog_server.com'' { > $syslog_type = "server" > include syslog > } > > node ''imasyslog_client.com'' { > include syslog > } > > class syslog { > file { syslog_conf: > path => "/etc/syslog-ng/syslog-ng.conf", > owner => "root", > group => "root", > mode => 440, > backup => main, > source => $syslog ? { > "server" => "puppet://puppet/dist/apps/syslog-ng/syslog- > server.conf", > default => "puppet://puppet/dist/apps/syslog-ng/syslog- > client.conf", > }, > notify => Service[syslog-ng] > } > } > > > e.g. Class inheritance > > node ''imasyslog_server.com'' { > include syslog_server > } > > node ''imasyslog_client.com'' { > include syslog > } > > class syslog { > file { syslog_conf: > path => "/etc/syslog-ng/syslog-ng.conf", > owner => "root", > group => "root", > mode => 440, > backup => main, > source => "puppet://puppet/dist/apps/syslog-ng/syslog- > client.conf", > notify => Service[syslog-ng] > } > } > > class syslog_server inherits syslog { > File["syslog_conf"] { > source => "puppet://puppet/dist/apps/syslog-ng/syslog- > server.conf", > } > } > > > HTH, > --Robert > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >
On Jun 6, 2007, at 3:53 PM, Jesse Nelson wrote:> thanks my initial hack was to just use a conditional source based > on $hostname but that is not a very robust way of doing it. > > I tried to use a veriable, but for some reason it wouldn''t work. I > think its scope ? not sure tho i inherit the base template for all > hosts even on a syslog server. > > i tried it like this > > node base { > include syslog_ng > } > > node default inherits base {} > > node syslogserver inherits base { > $syslog_type = server > }You should use a subclass here, not a variable. There are problems with variables and inheritance that make this not work. -- I wanna hang a map of the world in my house. Then I''m gonna put pins into all the locations that I''ve traveled to. But first, I''m gonna have to travel to the top two corners of the map so it won''t fall down. -- Mitch Hedberg --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
yup i ended up using a subclass was just wondering why this wouldn''t work. On Jun 6, 2007, at 2:46 PM, Luke Kanies wrote:> On Jun 6, 2007, at 3:53 PM, Jesse Nelson wrote: > > > thanks my initial hack was to just use a conditional source based > > on $hostname but that is not a very robust way of doing it. > > > > I tried to use a veriable, but for some reason it wouldn''t work. I > > think its scope ? not sure tho i inherit the base template for all > > hosts even on a syslog server. > > > > i tried it like this > > > > node base { > > include syslog_ng > > } > > > > node default inherits base {} > > > > node syslogserver inherits base { > > $syslog_type = server > > } > > You should use a subclass here, not a variable. There are problems > with variables and inheritance that make this not work. > > -- > I wanna hang a map of the world in my house. Then I''m gonna put pins > into all the locations that I''ve traveled to. But first, I''m gonna > have > to travel to the top two corners of the map so it won''t fall down. > -- Mitch Hedberg > > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >
On Jun 6, 2007, at 11:39 PM, Jesse Nelson wrote:> yup i ended up using a subclass was just wondering why this wouldn''t > work.It''s just a byproduct of how inheritance currently works, unfortunately. It works ok for classes, because you can override resource parameters, but you don''t normally put resources in node definitions so you can''t use overrides there. I could possibly fix this, but it makes more sense to just move to kinial, which is purpose-built to solve this kind of problem. -- I think that all good, right thinking people in this country are sick and tired of being told that all good, right thinking people in this country are fed up with being told that all good, right thinking people in this country are fed up with being sick and tired. I''m certainly not, and I''m sick and tired of being told that I am. -- Monty Python --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com