Hi, I have tested this cookbook, but the recursive mode don´t works on my recipe, ie, using no other type of parameter in the resource beyond the size, did not erase the contents of the subdirectory.
My testing:
Create a subdir /tmp/test and a lots of fake files in it:
mkdir -p /tmp/test
dd if=/dev/zero of=/tmp/test_file bs=1M count=30
dd if=/dev/zero of=/tmp/test_file bs=1M count=3000
dd if=/dev/zero of=/tmp/test/test_file bs=1M count=3000
dd if=/dev/zero of=/tmp/test/test_file2 bs=1M count=300
dd if=/dev/zero of=/tmp/test/test_file3 bs=1M count=300
dd if=/dev/zero of=/tmp/test/test_file4 bs=1M count=500
dd if=/dev/zero of=/tmp/test/test_file5 bs=1M count=980
My Test folder:
[vagrant@centera-sdk-bento-centos-73 ~]$ df -hP /tmp/test
Sist. Arq. Tam. Usado Disp. Uso% Montado em
/dev/mapper/cl-root 37G 9,4G 28G 26% /
[vagrant@centera-sdk-bento-centos-73 ~]$ ls -latrh /tmp/test
total 5,0G
-rwxr-xr-x. 1 vagrant vagrant 29K Jan 16 17:16 FPLibrary.jar
-rwxr-xr-x. 1 vagrant vagrant 409 Jan 16 17:16 test2.yml
drwxrwxrwt. 10 root root 184 Jan 16 17:22 ..
-rw-rw-r--. 1 vagrant vagrant 3,0G Jan 16 17:32 test_file
-rw-rw-r--. 1 vagrant vagrant 300M Jan 16 17:32 test_file2
-rw-rw-r--. 1 vagrant vagrant 300M Jan 16 17:32 test_file3
-rw-rw-r--. 1 vagrant vagrant 500M Jan 16 17:32 test_file4
drwxr-xr-x. 2 vagrant vagrant 133 Jan 16 17:33 .
-rw-rw-r--. 1 vagrant vagrant 980M Jan 16 17:33 test_file5
[vagrant@centera-sdk-bento-centos-73 ~]$
In my recipe (as it is in the README.md )
janitor_sweep '/tmp/' do
size '30M'
recursive true
action :purge
end
When I converge my cookbook:
Converging 4 resources
Recipe: prbbr-ops-limpeza-fs::default
* yum_package[ntp] action install (up to date)
* execute[timezone] action run
- execute timedatectl set-timezone America/Sao_Paulo
* execute[bkp_tz] action run (skipped due to only_if)
* janitor_sweep[/tmp/] action purge
Recipe: <Dynamically Defined Resource>
* file[/tmp/test_file] action delete
- delete file /tmp/test_file
- delete /tmp/test_file => 2018-01-16 3000.0 MB
Running handlers:
Running handlers complete
Chef Client finished, 3/5 resources updated in 18 seconds
Finished converging <centera-sdk-bento-centos-73> (0m26.04s).
-----> Kitchen is finished. (0m27.49s)
In the FileSystem:
Last login: Tue Jan 16 17:35:18 2018 from 192.168.121.1
[vagrant@centera-sdk-bento-centos-73 ~]$ ls -latrh /tmp/test
total 5,0G
-rwxr-xr-x. 1 vagrant vagrant 29K Jan 16 17:16 FPLibrary.jar
-rwxr-xr-x. 1 vagrant vagrant 409 Jan 16 17:16 test2.yml
-rw-rw-r--. 1 vagrant vagrant 3,0G Jan 16 17:32 test_file
-rw-rw-r--. 1 vagrant vagrant 300M Jan 16 17:32 test_file2
-rw-rw-r--. 1 vagrant vagrant 300M Jan 16 17:32 test_file3
-rw-rw-r--. 1 vagrant vagrant 500M Jan 16 17:32 test_file4
drwxr-xr-x. 2 vagrant vagrant 133 Jan 16 17:33 .
-rw-rw-r--. 1 vagrant vagrant 980M Jan 16 17:33 test_file5
drwxrwxrwt. 10 root root 167 Jan 16 17:36 ..
[vagrant@centera-sdk-bento-centos-73 ~]$
Thaks a Lot!
Hi, I have tested this cookbook, but the recursive mode don´t works on my recipe, ie, using no other type of parameter in the resource beyond the size, did not erase the contents of the subdirectory.
My testing:
Create a subdir /tmp/test and a lots of fake files in it:
My Test folder:
In my recipe (as it is in the
README.md)When I converge my cookbook:
In the FileSystem:
Thaks a Lot!