Skip to content

Commit fdf15e0

Browse files
committed
(maint) Add prune-reports subcommand
This adds a puppetserver subcommand to help garbage-collect old reports. The default TTL is the same as the one used for PuppetDB (14d), where this garbage collection is done automatically.
1 parent 2940eae commit fdf15e0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

resources/ext/cli/prune.erb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "Prune contents of report and bucket directories."
5+
echo
6+
echo "Usage: puppetserver prune <reportdir|bucketdir> [<ttl>]"
7+
echo " bucketdir|reportdir work on either bucketdir or reportdir"
8+
echo " <ttl> delete data older than this amount of time (default: 14d)"
9+
}
10+
11+
prune() {
12+
DIR="$1"
13+
AGE=${2:-14d}
14+
puppet apply --no-report --log_level=warning -e "tidy { \$settings::${DIR}: age=>'${AGE}', recurse=>true, rmdirs=>true }"
15+
}
16+
17+
case $1 in
18+
-h|--help)
19+
usage
20+
exit 0
21+
;;
22+
bucketdir|reportdir)
23+
prune "$1" "$2"
24+
;;
25+
*)
26+
echo "Error: unknown argument."
27+
usage
28+
exit 1
29+
;;
30+
esac

0 commit comments

Comments
 (0)