New to Kestra?
Use blueprints to kickstart your first workflows.
Remote disk cleanup with Kestra over SSH: allowlist guardrail, pre/post disk metrics, approval gate for production hosts, Docker prune, and Slack alerts.
Free disk space on remote Linux servers without giving everyone root and a shell. This blueprint SSHes into a target host, measures disk usage, pauses for human approval when the host looks production-like, then removes week-old temp files, prunes unused Docker images, and force-rotates logs. A hard allowlist stops anyone from pointing it at an arbitrary machine, results are posted to Slack, and each targeted host is tracked as a Kestra Asset so you can see which servers were cleaned and when.
validate_host task (io.kestra.plugin.core.execution.Fail with runIf) rejects any target_host that is not in the allowed_hosts variable and does not match the svp- naming prefix.pre_cleanup_metrics task (io.kestra.plugin.fs.ssh.Command) records the root filesystem usage percentage before any change.wait_for_approval task (io.kestra.plugin.core.flow.Pause) only activates when the host name contains srv-app and force_cleanup is false, so production-like machines require an explicit resume while dev boxes flow straight through.run_cleanup task executes sudo find /tmp -type f -atime +7 -delete, sudo docker image prune -af --filter "until=168h", and sudo logrotate -f /etc/logrotate.conf. Its assets block registers the host as a io.kestra.plugin.ee.assets.VM asset with operation: disk_cleanup metadata.post_cleanup_metrics task captures used and free space after cleanup, and notify_slack posts the report; a flow-level errors handler alerts on any failure.pluginDefaults block injects host, username, and privateKey into every io.kestra.plugin.fs.ssh task, so connection settings live in exactly one place.A cron script on each host cannot pause for approval, cannot centralize its allowlist, and leaves no shared record of what ran where. Kestra provides conditional runIf guardrails, a first-class Pause gate, pluginDefaults to avoid repeating connection details, centralized secrets for the SSH key, error handling with Slack alerts, and an asset catalog entry per maintained host.
sudo.assets block to run on OSS).SSH_PRIVATE_KEY: private key for the remote_user account on target hosts.SLACK_WEBHOOK_URL: Slack incoming webhook for maintenance reports and failure alerts.allowed_hosts and the naming-prefix guardrail to match your fleet.force_cleanup: true to validate connectivity.io.kestra.plugin.core.flow.ForEach.journalctl --vacuum-time=7d) or package cache cleanup steps.