Hi all, I''m going out of my mind trying to get my head around inheritance in Puppet 0.25. I have a module named smtp which contains a number of classes for setting up the various configurations that we have for SMTP Servers based on Exim. I have a class called SMTP which has a service defined as "exim". I have a sub-class named smtpexternal which contains a configuration file provided from the smtp module and which needs to notify the "exim" service defined in the smtp class. The simplified version is as follows: class smtp { package {"exim-mysql": ensure => ''installed''; } service{"sendmail": ensure => stopped, } package{"sendmail": ensure => absent, } # sendmail uninstalls the LSB, so we need to re-install it here... :( package{"redhat-lsb": ensure => installed; } iptables{"SMTP Access for Exim": proto => "tcp", dport => "25", jump => "ACCEPT", } service{ "exim": ensure => "running", hasrestart => true, } class smtpexternal{ include ''mysql'' file{"external-exim.conf": source => "puppet:///modules/smtp/external-exim.conf", owner => "root", group => "mail", mode => "440", path => "/etc/exim/exim.conf", notify => Service[''exim''] } } } The issue I have is that when I include the smtp::smtpexternal class on a node, it errors with the following: err: Could not run Puppet configuration client: Could not find dependent Service[exim] for File[external-exim.conf] at /usr/share/puppet/modules/smtp/manifests/init.pp How do I get smtpexternal to notify smtp''s exim service - or am I approaching this from the wrong direction? Thanks in advance, Matt -- 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.
You need to include or inherit the class that defines the service before you can notify it. (Or just redefine the service in the other module.) There is no link between smtpexternal and smtp. On Tue, Sep 28, 2010 at 12:15 PM, Matt Wallace <lists@truthisfreedom.org.uk>wrote:> > Hi all, > > I''m going out of my mind trying to get my head around inheritance in Puppet > 0.25. > > I have a module named smtp which contains a number of classes for setting > up > the various configurations that we have for SMTP Servers based on Exim. > > I have a class called SMTP which has a service defined as "exim". > > I have a sub-class named smtpexternal which contains a configuration file > provided from the smtp module and which needs to notify the "exim" service > defined in the smtp class. > > The simplified version is as follows: > > class smtp { > > package {"exim-mysql": > ensure => ''installed''; > } > > service{"sendmail": > ensure => stopped, > } > > package{"sendmail": > ensure => absent, > } > > # sendmail uninstalls the LSB, so we need to re-install it here... > :( > package{"redhat-lsb": > ensure => installed; > } > > iptables{"SMTP Access for Exim": > proto => "tcp", > dport => "25", > jump => "ACCEPT", > } > service{ "exim": > ensure => "running", > hasrestart => true, > } > > class smtpexternal{ > > include ''mysql'' > > file{"external-exim.conf": > source => "puppet:///modules/smtp/external-exim.conf", > owner => "root", > group => "mail", > mode => "440", > path => "/etc/exim/exim.conf", > notify => Service[''exim''] > } > } > } > > The issue I have is that when I include the smtp::smtpexternal class on a > node, it errors with the following: > > err: Could not run Puppet configuration client: Could not find dependent > Service[exim] for File[external-exim.conf] at > /usr/share/puppet/modules/smtp/manifests/init.pp > > > How do I get smtpexternal to notify smtp''s exim service - or am I > approaching > this from the wrong direction? > > Thanks in advance, > > Matt > > -- > 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.
On 09/28/2010 06:20 PM, Disconnect wrote:> You need to include or inherit the class that defines the service before you > can notify it. (Or just redefine the service in the other module.) > > There is no link between smtpexternal and smtp.To clarify: Nesting a class inside another lexically does not imply inheritance. It can still be worthwile: class smtp { ... class external inherits smtp { ... } } You can then include smtp::external you want the subclass. We have found this to be a sensible convention. Regards, Felix> On Tue, Sep 28, 2010 at 12:15 PM, Matt Wallace > <lists@truthisfreedom.org.uk>wrote: > >> >> Hi all, >> >> I''m going out of my mind trying to get my head around inheritance in Puppet >> 0.25. >> >> I have a module named smtp which contains a number of classes for setting >> up >> the various configurations that we have for SMTP Servers based on Exim. >> >> I have a class called SMTP which has a service defined as "exim". >> >> I have a sub-class named smtpexternal which contains a configuration file >> provided from the smtp module and which needs to notify the "exim" service >> defined in the smtp class. >> >> The simplified version is as follows: >> >> class smtp { >> >> package {"exim-mysql": >> ensure => ''installed''; >> } >> >> service{"sendmail": >> ensure => stopped, >> } >> >> package{"sendmail": >> ensure => absent, >> } >> >> # sendmail uninstalls the LSB, so we need to re-install it here... >> :( >> package{"redhat-lsb": >> ensure => installed; >> } >> >> iptables{"SMTP Access for Exim": >> proto => "tcp", >> dport => "25", >> jump => "ACCEPT", >> } >> service{ "exim": >> ensure => "running", >> hasrestart => true, >> } >> >> class smtpexternal{ >> >> include ''mysql'' >> >> file{"external-exim.conf": >> source => "puppet:///modules/smtp/external-exim.conf", >> owner => "root", >> group => "mail", >> mode => "440", >> path => "/etc/exim/exim.conf", >> notify => Service[''exim''] >> } >> } >> } >> >> The issue I have is that when I include the smtp::smtpexternal class on a >> node, it errors with the following: >> >> err: Could not run Puppet configuration client: Could not find dependent >> Service[exim] for File[external-exim.conf] at >> /usr/share/puppet/modules/smtp/manifests/init.pp >> >> >> How do I get smtpexternal to notify smtp''s exim service - or am I >> approaching >> this from the wrong direction?-- 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.
On Wednesday 29 Sep 2010 08:15:08 Felix Frank wrote:> On 09/28/2010 06:20 PM, Disconnect wrote: > > You need to include or inherit the class that defines the service before > > you can notify it. (Or just redefine the service in the other module.) > > > > There is no link between smtpexternal and smtp. > > To clarify: Nesting a class inside another lexically does not imply > inheritance. It can still be worthwile: > > class smtp { > ... > class external inherits smtp { > ... > } > } > > You can then include smtp::external you want the subclass. We have found > this to be a sensible convention.Thanks both, That now works fine. Kind regards. Matt -- 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.