Puppet's filebucket serves as a versioned backup system for files managed by Puppet. When Puppet makes changes to files on managed nodes, it stores the original content in a filebucket before applying modifications. This provides an essential safety net for configuration management.
To store filebucket data on a single Puppet master server, configure your Puppet master's puppet.conf
:
[master] filebucket = puppet server = puppetmaster.example.com
For clients to use this centralized bucket:
[agent] filebucket = puppet server = puppetmaster.example.com
When declaring file resources that should use the filebucket:
file { '/etc/important_config': ensure => file, source => 'puppet:///modules/mymodule/important_config', backup => 'puppet', }
To ensure secure transfers between client and master:
- Use standard Puppet PKI infrastructure (SSL/TLS)
- Configure
auth.conf
to properly authorize filebucket access - Set appropriate filesystem permissions on the bucket directory
To list contents of the filebucket:
puppet filebucket list -l --bucket /var/lib/puppet/clientbucket
To retrieve a specific file version:
puppet filebucket get /var/lib/puppet/clientbucket/md5/d41d8cd98f00b204e9800998ecf8427e
Create a custom script to remove files older than 30 days:
find /var/lib/puppet/clientbucket -type f -mtime +30 -exec rm -f {} \;
Or implement a more sophisticated solution with log rotation:
/var/lib/puppet/clientbucket/*.log { daily rotate 7 compress delaycompress missingok notifempty }
For production environments, consider this enhanced configuration:
[master] filebucket = main server = puppetmaster.example.com bucketdir = /opt/puppetlabs/server/data/puppetserver/bucket bucket_restrictions = filebucket [agent] filebucket = main report = true
Puppet's filebucket serves as a versioned backup system for files managed by Puppet. When configured properly, it provides:
- Version control for all file resources
- Disaster recovery capabilities
- Audit trail of file changes
To configure a centralized filebucket on your Puppet master, add these settings to puppet.conf
:
[master] filebucket = puppet bucketdir = /opt/puppetlabs/server/data/puppetserver/bucket rest = true
For clients to use this centralized bucket:
[main] filebucket = main:server = puppet
Ensure encrypted communication between clients and master:
[master] ssl_client_header = SSL_CLIENT_S_DN ssl_client_verify_header = SSL_CLIENT_VERIFY
Verify your certificates are properly configured:
puppet cert list --all
Common operations with examples:
# Backup a file puppet filebucket backup /etc/ntp.conf --bucket server://puppet # Retrieve file by content checksum puppet filebucket get md5/123abc456def --bucket server://puppet # Diff between versions puppet filebucket diff md5/123abc md5/456def --bucket server://puppet
Create a custom script for maintenance:
#!/bin/bash # Prune files older than 90 days find /opt/puppetlabs/server/data/puppetserver/bucket -type f -mtime +90 -delete # Generate audit report puppet filebucket list --bucket server://puppet > filebucket_audit_$(date +%F).log
If files aren't backing up:
# Debug filebucket operations puppet agent -t --debug --logdest syslog # Verify bucket permissions ls -la /opt/puppetlabs/server/data/puppetserver/bucket