Skip to content

Commit

Permalink
(maint) Add prune-reports subcommand
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jcharaoui committed Aug 31, 2024
1 parent 2940eae commit fdf15e0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions resources/ext/cli/prune.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

usage() {
echo "Prune contents of report and bucket directories."
echo
echo "Usage: puppetserver prune <reportdir|bucketdir> [<ttl>]"
echo " bucketdir|reportdir work on either bucketdir or reportdir"
echo " <ttl> delete data older than this amount of time (default: 14d)"
}

prune() {
DIR="$1"
AGE=${2:-14d}
puppet apply --no-report --log_level=warning -e "tidy { \$settings::${DIR}: age=>'${AGE}', recurse=>true, rmdirs=>true }"
}

case $1 in
-h|--help)
usage
exit 0
;;
bucketdir|reportdir)
prune "$1" "$2"
;;
*)
echo "Error: unknown argument."
usage
exit 1
;;
esac

0 comments on commit fdf15e0

Please sign in to comment.