On Thursday, October 11, 2012 5:07:36 PM UTC-5, Ygor wrote: 

Either puppet-resource-type "tidy" is busted or I do not properly understand 
its use. 

Red Had Enterprise Linux 5.8 server (x86_64) 
I am seeing this behavior on both Puppet 2.6.17 and 2.7.19 

I want to "tidy" up a path -- let's say /volume/foo/bar/ (bar is a directory) 

The resource definition is: 

tidy { '/volume/foo/bar/': 
age => '0', 
recurse => true, 
rmdirs => true, 
} 

To test it, I do the following 

cd /volume/foo/bar/ 
mkdir 1 2 3 4 5 6 
touch 1/a 2/b 3/c 4/d 5/e 6/f 6/g 

then I run puppet. 
It deletes all the "touched" files (a, b, c, d, e, f, g) 

Now for The Problem: 
When I run puppet again, I am expecting the empty directories ( 1/ 2/ 3/ 4/ 5/ 
6/ ) to get deleted. 
They are not removed. Even though the "rmdirs" parameter is set to true. 

Is this the way "tidy" is supposed to work ? 






That behavior is not consistent with my reading of the docs. There is 
definitely a bug there. I speculate that it might be related to the fact that 
recursing the subdirectories necessarily updates their atimes, which is what 
'tidy' looks at by default to compute an age. It still should work even then, 
however, because it should not be possible that way to produce an age less than 
zero. You should file a ticket. 

You could try to work around it by setting a negative 'age' parameter and / or 
by changing the 'type' to 'mtime' (last modification time) or even 'ctime' 
(creation time). Note that using 'mtime' might have similar implications for 
nonempty directories as 'atime' may have for empty ones (removing contents 
should update directory mtimes, possibly producing an issue with 'age') but at 
least you would then expect the then-empty directories to be cleaned up on the 
next Puppet run. 


John 

Thanks for responding, John. 

I saw other discussions about "tidy" that mentioned the same thing, so I 
started tinkering. 

If I use mtime or ctime, directories get deleted, which is great, but it also 
deleted the top of the tree -- /volume/foo/bar/ in my example. 
I found a workaround, but I think it is ugly. 

Looking at the output, tidy must generate temporary resources to delete the 
files and directories. 

I see: 
notice: /Stage[main]//Node[server.foo.org]/Tidy[/volume/foo/bar]: Tidying 
File[/volume/foo/bar/] 
notice: /Stage[main]//Node[server.foo.org]/Tidy[/volume/foo/bar]: Tidying 
File[/volume/foo/bar/1] 
notice: /Stage[main]//Node[server.foo.org]/Tidy[/volume/foo/bar]: Tidying 
File[/volume/foo/bar/1/a] 
... 
and then 
notice: /File[/volume/foo/bar/1/a]/ensure: removed 
notice: /File[/volume/foo/bar/1]/ensure: removed 
... 


If I declare a file resource for /volume/foo/bar/ with ensure => present, the 
puppet run output says: 
info: /File[/volume/foo/bar]: Duplicate generated resource; skipping 

Seems like a klooodjy way to do it but...? 

“Sometimes I think the surest sign that intelligent life exists elsewhere in 
the universe is that none of it has tried to contact us.” 
Bill Waterson (Calvin & Hobbes) 



-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to