| Puppet Version: 6.25.0 & 7.12.0 Puppet Server Version: 7.4.1 OS Name/Version: Debian-10 Buster The type documentation for tidy has the following description for the rmdirs parameter: Tidy directories in addition to files; that is, remove directories whose age is older than the specified criteria. This will only remove empty directories, so all contained files must also be tidied before a directory gets removed. It seems that directories are removed when in fact they are not empty (which removes files that should not be removed). Also the value mtime for the parameter type seems to be important to trigger the issue. Use the following manifest tidy.pp:
tidy { '/tmp/tidy': |
age => '1m', |
rmdirs => true, |
recurse => true, |
type => 'mtime', |
}
|
Run the following shell script:
#!/bin/sh -x |
mkdir /tmp/tidy |
touch /tmp/tidy/file1 |
sleep 70 |
touch /tmp/tidy/file2 |
puppet apply --verbose tidy.pp |
|
The script creates a directory and a file in it. The it waits 70 seconds to ensure the file modification time is more that one minute ago. It creates anothe file and runs the manifest. Puppet should remove files/directories where the modification time is more than 1 minute ago. Desired Behavior: Since /tmp/tidy/file2 is less than one minute old, it should still exist after Puppet is done. Actual Behavior: The directory /tmp/tidy including the file /tmp/tidy/file2 is removed by Puppet. The output of the script:
+ mkdir /tmp/tidy |
+ touch /tmp/tidy/file1 |
+ sleep 70 |
+ touch /tmp/tidy/file2 |
+ puppet apply --verbose tidy.pp |
Notice: Compiled catalog for puppet.example.com in environment production in 0.04 seconds |
Info: Using environment 'production' |
Notice: /Stage[main]/Main/Tidy[/tmp/tidy]: Tidying 1 files |
Info: Applying configuration version '1636391335' |
Notice: /Stage[main]/Main/File[/tmp/tidy/file1]/ensure: removed |
Notice: Applied catalog in 0.02 seconds |
The removal of /tmp/tidy is clearly shown in the log.  |