chandan kumar
2012-Oct-27 02:21 UTC
[Puppet Users] Over riding global settings/class/variables at node level
Hello, I am new to puppet programming. I have encountered a problem where the a global setting, application to all servers, nodes across the board to enable a particular service such as rsyslog. And I want to have a server that should not run rsyslog rather it should run syslog-ng. So basically I am having two classes in the same node, one is saying start rsyslog and another (my class) is saying to stop rsyslog and start syslog-ng. Whenever I run this it shows duplication definition error. So one class is doing service {''rsyslog'': enable => true} another class service {''rsyslog'': ensure => stopped} err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Service[rsyslog] is already defined in file /etc/puppet/environments/syslog/manifests/classes/enabled-c6.pp at line 8; cannot redefine at /etc/puppet/environments/syslog/modules/syslog_ng/manifests/service.pp:5 on node test-logserver Thanks Chandan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/ZSoJuyKXAkUJ. 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.
Aaron Stone
2012-Oct-27 19:03 UTC
Re: [Puppet Users] Over riding global settings/class/variables at node level
Rules are not run in order, so there''s nothing to indicate to Puppet which of those contradictory rules should win. Puppet also enforces a uniqueness on the pair (type, name) -- (''service'', ''rsyslog'') is unique and you cannot have another one. What you''ll need to do is make sure that only one of those rules applies to any one host. Good luck! Aaron On Fri, Oct 26, 2012 at 7:21 PM, chandan kumar <chandank.kumar@gmail.com> wrote:> Hello, > > I am new to puppet programming. I have encountered a problem where the a > global setting, application to all servers, nodes across the board to enable > a particular service such as rsyslog. And I want to have a server that > should not run rsyslog rather it should run syslog-ng. > > So basically I am having two classes in the same node, one is saying start > rsyslog and another (my class) is saying to stop rsyslog and start > syslog-ng. Whenever I run this it shows duplication definition error. > > So one class is doing > > service {''rsyslog'': enable => true} > > another class > > service {''rsyslog'': ensure => stopped} > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Duplicate definition: Service[rsyslog] is already defined in file > /etc/puppet/environments/syslog/manifests/classes/enabled-c6.pp at line 8; > cannot redefine at > /etc/puppet/environments/syslog/modules/syslog_ng/manifests/service.pp:5 on > node test-logserver > > Thanks > > Chandan > > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/ZSoJuyKXAkUJ. > 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.-- 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.
Ramin K
2012-Oct-27 19:33 UTC
Re: [Puppet Users] Over riding global settings/class/variables at node level
On 10/26/2012 7:21 PM, chandan kumar wrote:> Hello, > > I am new to puppet programming. I have encountered a problem where the a > global setting, application to all servers, nodes across the board to > enable a particular service such as rsyslog. And I want to have a server > that should not run rsyslog rather it should run syslog-ng. > > So basically I am having two classes in the same node, one is saying > start rsyslog and another (my class) is saying to stop rsyslog and start > syslog-ng. Whenever I run this it shows duplication definition error. > > So one class is doing > > service {''rsyslog'': enable => true} > > another class > > service {''rsyslog'': ensure => stopped} > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Duplicate definition: Service[rsyslog] is already defined in file > /etc/puppet/environments/syslog/manifests/classes/enabled-c6.pp at line > 8; cannot redefine at > /etc/puppet/environments/syslog/modules/syslog_ng/manifests/service.pp:5 > on node test-logserverOne solution is to create the following class. modules/rsyslog/manifests/service/disable.pp class rsyslog::service::disable inherits rsyslog::service { Service[''rsyslog''] { ensure => stopped, enable => false, } } assuming you have something like this node basenode { include rsyslog } Then you''d add the addition class to override the original functionality. node ''someserver'' inherits basenode { include syslog_ng include rsyslog::service::disable } Or if syslog_ng and rsyslog can never coexist, I''d include the disable class directly in the init.pp of your syslog_ng class. Ramin -- 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.
chandan kumar
2012-Oct-30 16:51 UTC
Re: [Puppet Users] Over riding global settings/class/variables at node level
Thanks for the response. I am able to fix the problem class syslog_ng::service inherits standard-services { Service[''rsyslog''] { enable => false, ensure => stopped, } service { ''syslog-ng'': ensure => running, enable => true, require => Class[''syslog_ng::install''] } } On Saturday, 27 October 2012 12:33:14 UTC-7, Ramin K wrote:> > On 10/26/2012 7:21 PM, chandan kumar wrote: > > Hello, > > > > I am new to puppet programming. I have encountered a problem where the a > > global setting, application to all servers, nodes across the board to > > enable a particular service such as rsyslog. And I want to have a server > > that should not run rsyslog rather it should run syslog-ng. > > > > So basically I am having two classes in the same node, one is saying > > start rsyslog and another (my class) is saying to stop rsyslog and start > > syslog-ng. Whenever I run this it shows duplication definition error. > > > > So one class is doing > > > > service {''rsyslog'': enable => true} > > > > another class > > > > service {''rsyslog'': ensure => stopped} > > > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > > Duplicate definition: Service[rsyslog] is already defined in file > > /etc/puppet/environments/syslog/manifests/classes/enabled-c6.pp at line > > 8; cannot redefine at > > /etc/puppet/environments/syslog/modules/syslog_ng/manifests/service.pp:5 > > on node test-logserver > > One solution is to create the following class. > > modules/rsyslog/manifests/service/disable.pp > class rsyslog::service::disable inherits rsyslog::service { > Service[''rsyslog''] { ensure => stopped, enable => false, } > } > > assuming you have something like this > node basenode { > include rsyslog > } > > Then you''d add the addition class to override the original functionality. > node ''someserver'' inherits basenode { > include syslog_ng > include rsyslog::service::disable > } > > Or if syslog_ng and rsyslog can never coexist, I''d include the disable > class directly in the init.pp of your syslog_ng class. > > Ramin >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/lenskww7jWYJ. 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.