So I have the following: define nagios::service ( $nagios_template = ''service-template'', $host_name = $fqdn, $service_groups = '''', $contact_groups = $default_contact_group, $max_check_attempts = 3, $dependency = false, $dependent_host = $fqdn, $dependent_service = '''', $check_command = '''' ) { @@file { $name: name => "/etc/nagios/conf.d/services/${fqdn}_${name}.cfg", mode => 0644, owner => nagios, group => nagios, content => template("nagios/service.erb"), } } then in the server class I have: file { [ "${nagios_dir}/conf.d/", "${nagios_dir}/conf.d/hosts", "${nagios_dir}/conf.d/services" ]: ensure => directory, purge => true, recurse => true, } Exporting the resources works fine, collecting them works great as well. The issue is that once a resource has been exported if it is then removed from wherever it is defined the collected file isn''t purged. I can remove it manually and puppet doesn''t recreate it but it''s an unmanaged resource that I''m instructing it to purge and it''s not. In a more concrete example if I do: nagios::server { FOO: } run puppet... file is created appropriatly everything is happy I now remove nagios::server { FOO: } the file isn''t removed despite the directory being purged I added a tidy rule at one point and that seems to clean things up, but what happens is it does the purge, then recreates the file resource b/c it''s missing. Bug? Feature? Missing Feature? User Misunderstanding? C -- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Nov 20, 2007, at 11:47 PM, Chris MacLeod wrote:> Exporting the resources works fine, collecting them works great as > well. > The issue is that once a resource has been exported if it is then > removed from wherever it is defined the collected file isn''t purged. > I can remove it manually and puppet doesn''t recreate it but it''s an > unmanaged resource that I''m instructing it to purge and it''s not. > > In a more concrete example if I do: > > nagios::server { FOO: } > run puppet... > file is created appropriatly everything is happy > I now remove nagios::server { FOO: } > the file isn''t removed despite the directory being purged > > > I added a tidy rule at one point and that seems to clean things up, > but what happens is it does the purge, then recreates the file > resource b/c it''s missing. > > > Bug? Feature? Missing Feature? User Misunderstanding?And you''re sure this doesn''t happen for normal resources? That is, you''re sure purging is working, just not of collected resources? Because really, the client has no idea that a resource is collected vs. being specified as part of its configuration, so it''d be very strange if they behaved differently. (I should actually retain that knowledge on the client, because it would at least be useful for logging.) Have you verified that the resource is no longer in the cached configuration? -- When I die, I want go out just like my grandfather, in his sleep, peaceful and quiet...not kicking and screaming like the other guys in his car. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On 11/21/07, Luke Kanies <luke@madstop.com> wrote:> > On Nov 20, 2007, at 11:47 PM, Chris MacLeod wrote: > > > Exporting the resources works fine, collecting them works great as > > well. > > The issue is that once a resource has been exported if it is then > > removed from wherever it is defined the collected file isn''t purged. > > I can remove it manually and puppet doesn''t recreate it but it''s an > > unmanaged resource that I''m instructing it to purge and it''s not. > > > > In a more concrete example if I do: > > > > nagios::server { FOO: } > > run puppet... > > file is created appropriatly everything is happy > > I now remove nagios::server { FOO: } > > the file isn''t removed despite the directory being purged > > > > > > I added a tidy rule at one point and that seems to clean things up, > > but what happens is it does the purge, then recreates the file > > resource b/c it''s missing. > > > > > > Bug? Feature? Missing Feature? User Misunderstanding? > > And you''re sure this doesn''t happen for normal resources? That is, > you''re sure purging is working, just not of collected resources?Looks like you are right. I changed my manifests so that those resource were not exported and not collected (just used normally) and the purge still fails to happen in that case. So not specifically an exported issue, but a general purge issue. I am expecting the correct behavior for purge/recurse here? C -- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Nov 21, 2007, at 10:37 AM, Chris MacLeod wrote:> Looks like you are right. I changed my manifests so that those > resource were not exported and not collected (just used normally) > and the purge still fails to happen in that case. So not > specifically an exported issue, but a general purge issue. > > I am expecting the correct behavior for purge/recurse here?What happens if you remove the ''ensure'' from that setting? I know you won''t get the behaviour you want in terms of creating directories, but that might be the problem. -- Men will wrangle for religion; write for it; fight for it; die for it; anything but live for it. --Charles Caleb Colton --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On 11/21/07, Luke Kanies <luke@madstop.com> wrote:> > On Nov 21, 2007, at 10:37 AM, Chris MacLeod wrote: > > > Looks like you are right. I changed my manifests so that those > > resource were not exported and not collected (just used normally) > > and the purge still fails to happen in that case. So not > > specifically an exported issue, but a general purge issue. > > > > I am expecting the correct behavior for purge/recurse here? > > What happens if you remove the ''ensure'' from that setting? I know > you won''t get the behaviour you want in terms of creating > directories, but that might be the problem.no effect, the file in question still isn''t purged. --> Men will wrangle for religion; write for it; fight for it; die for it; > anything but live for it. --Charles Caleb Colton > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >-- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Nov 21, 2007, at 11:16 AM, Chris MacLeod wrote:> > What happens if you remove the ''ensure'' from that setting? I know > you won''t get the behaviour you want in terms of creating > directories, but that might be the problem. > > > no effect, the file in question still isn''t purged.So just to be clear, purging on files doesn''t work for you at all? What about if you do a small isolated test? -- It is said that power corrupts, but actually it''s more true that power attracts the corruptible. The sane are usually attracted by other things than power. -- David Brin --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
so a small isolated example does work (shown below) --/tmp/purge.pp-- file { "/tmp/testdirectory": ensure => directory, purge => true, recurse => true, } file { "/tmp/testdirectory/testfile": ensure => present, source => "/etc/services", } puppet -v /tmp/purge.pp info: mount[localhost]: Mounted / info: mount[modules]: Mounted notice: //File[/tmp/testdirectory]/ensure: created notice: //File[/tmp/testdirectory/testfile]/ensure: created psychosis:~ cmacleod$ vi /tmp/purge.pp # I comment out the testfile object psychosis:~ cmacleod$ puppet -v /tmp/purge.pp info: //File[/tmp/testdirectory/testfile]: Filebucketed to puppet with sum 6591b0b9196c5fe81eb9c25fbaaf25cd notice: //File[/tmp/testdirectory/testfile]/ensure: removed It also works fine if I wrap the file creation inside a custom define. So I''m not sure what''s different in my module than in this isolated test. I''ve put up my module (http://stick.miscellaneous.net/repos/nagios.git) if anyone has any insight into what may be happening (or if they are interested) C On 11/21/07, Luke Kanies <luke@madstop.com> wrote:> > On Nov 21, 2007, at 11:16 AM, Chris MacLeod wrote: > > > > What happens if you remove the ''ensure'' from that setting? I know > > you won''t get the behaviour you want in terms of creating > > directories, but that might be the problem. > > > > > > no effect, the file in question still isn''t purged. > > So just to be clear, purging on files doesn''t work for you at all? > What about if you do a small isolated test? > > -- > It is said that power corrupts, but actually it''s more true that power > attracts the corruptible. The sane are usually attracted by other > things > than power. -- David Brin > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >-- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
so I did some additional testing and I think I''ve found something (interesting at least) if you create a file object similar to my example that recursively purges it''ll work find. Unless you set owner and group attributes on that directory. Once that is done the purge will stop working (silently). However if you then later add a source for that directory that is empty the purge will start working again. At some point I think DavidS commented on this and if you look through his modules in several places he uses: source => "puppet://${server}/common/empty", which doesn''t actually exist. It seems to me to be a bug that setting attributes on a directory causes purge to stop working, but at least there is a workaround. If it''s a bug I''ll file it, but if it''s deemed not to be one (or so difficult to fix) I''ll add a FAQ entry for it since it''s come up a couple of times. C On 11/22/07, Chris MacLeod <stickm@gmail.com> wrote:> > so a small isolated example does work (shown below) > > --/tmp/purge.pp-- > file { "/tmp/testdirectory": > ensure => directory, > purge => true, > recurse => true, > } > > > file { "/tmp/testdirectory/testfile": > ensure => present, > source => "/etc/services", > } > > > puppet -v /tmp/purge.pp > info: mount[localhost]: Mounted / > info: mount[modules]: Mounted > notice: //File[/tmp/testdirectory]/ensure: created > notice: //File[/tmp/testdirectory/testfile]/ensure: created > psychosis:~ cmacleod$ vi /tmp/purge.pp # I comment out the testfile object > psychosis:~ cmacleod$ puppet -v /tmp/purge.pp > info: //File[/tmp/testdirectory/testfile]: Filebucketed to puppet with sum > 6591b0b9196c5fe81eb9c25fbaaf25cd > notice: //File[/tmp/testdirectory/testfile]/ensure: removed > > > > > It also works fine if I wrap the file creation inside a custom define. > > So I''m not sure what''s different in my module than in this isolated test. > > > I''ve put up my module ( http://stick.miscellaneous.net/repos/nagios.git) > if anyone has any insight into what may be happening (or if they are > interested) > > > C > > On 11/21/07, Luke Kanies <luke@madstop.com> wrote: > > > > On Nov 21, 2007, at 11:16 AM, Chris MacLeod wrote: > > > > > > What happens if you remove the ''ensure'' from that setting? I know > > > you won''t get the behaviour you want in terms of creating > > > directories, but that might be the problem. > > > > > > > > > no effect, the file in question still isn''t purged. > > > > So just to be clear, purging on files doesn''t work for you at all? > > What about if you do a small isolated test? > > > > -- > > It is said that power corrupts, but actually it''s more true that power > > attracts the corruptible. The sane are usually attracted by other > > things > > than power. -- David Brin > > --------------------------------------------------------------------- > > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > > -- > stickm@gmail.com > -==< Stick >==- >-- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Chris MacLeod schrieb:> so I did some additional testing and I think I''ve found something > (interesting at least) > > if you create a file object similar to my example that recursively > purges it''ll work find. > Unless you set owner and group attributes on that directory. Once that > is done the purge will stop working (silently). However if you then > later add a source for that directory that is empty the purge will start > working again. > > At some point I think DavidS commented on this and if you look through > his modules in several places he uses: > > source => "puppet://${server}/common/empty", > which doesn''t actually exist. > > It seems to me to be a bug that setting attributes on a directory causes > purge to stop working, but at least there is a workaround. If it''s a > bug I''ll file it, but if it''s deemed not to be one (or so difficult to > fix) I''ll add a FAQ entry for it since it''s come up a couple of times.There is even a ticket with a comment from Luke: http://reductivelabs.com/trac/puppet/ticket/594> Given the following code: > > file { "/tmp/testing": source => "/tmp/source", purge => true, owner > => luke, recurse => true > > Puppet considers all of the contained files to be managed (and thus > not purgeable) because you''re specifying the owner. > > I''ve added a special-case in [2436] that purges files that aren''t on > the remote system, but I''m not sure this is the right long-term > solution.Regards, DavidS
On Nov 23, 2007, at 12:35 AM, Chris MacLeod wrote:> so I did some additional testing and I think I''ve found something > (interesting at least) > > if you create a file object similar to my example that recursively > purges it''ll work find. > Unless you set owner and group attributes on that directory. Once > that is done the purge will stop working (silently). However if > you then later add a source for that directory that is empty the > purge will start working again. > > At some point I think DavidS commented on this and if you look > through his modules in several places he uses: > > source => "puppet://${server}/common/empty", > which doesn''t actually exist. > > It seems to me to be a bug that setting attributes on a directory > causes purge to stop working, but at least there is a workaround. > If it''s a bug I''ll file it, but if it''s deemed not to be one (or so > difficult to fix) I''ll add a FAQ entry for it since it''s come up a > couple of times.As David mentioned, this is probably a design bug, but I can''t come up with a better way to do it. Please do add it to the FAQ. I think the real fix is to provide a way to differentiate between managing the directory and its contents, so you can create the dir and set its mode/etc., but then purge its contents. -- The only difference between the Democrats and the Republicans is that the Democrats allow the poor to be corrupt, too. -- Oscar Levant --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com