Skip to content

Commit f7942dc

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 f7942dc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

resources/ext/cli/prune-reports.erb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
usage() {
4+
echo "Usage: puppetserver prune-reports [<ttl>]"
5+
echo " <ttl> delete reports older than this amount of time (default: 14d)"
6+
exit 0
7+
}
8+
9+
prune() {
10+
AGE=${1:-14d}
11+
puppet apply --no-report --log_level=warning -e "tidy { \$settings::reportdir: age=>'$AGE', recurse=>true, rmdirs=>true }"
12+
}
13+
14+
case $1 in
15+
-h|--help)
16+
usage
17+
;;
18+
*)
19+
prune "$1"
20+
;;
21+
esac

0 commit comments

Comments
 (0)