Complete Guide to Backup and Restore Puppet Master Serve
Puppet Master Server Backup Guide
1. Prepare for Backup
Ensure you have working backups of the Primary, Replica, and Compilers. Before initiating the backup, stop the pe_databases
module timers to prevent pg_repack
from interfering:
systemctl stop pe_databases-*.timer
2. Create Backup
Run the backup command on the Primary server:
sudo puppet-backup create --dir=<BACKUP_DIRECTORY> --name=<BACKUP_NAME>
3. Backup Secret Keys
Secure the secret keys used by Orchestration and LDAP services:
- Orchestration:
/etc/puppetlabs/orchestration-services/conf.d/secrets/
- LDAP (if applicable):
/etc/puppetlabs/console-services/conf.d/secrets/keys.json
4. Restart Database Timers
systemctl start pe_databases-catalogs.timer pe_databases-facts.timer pe_databases-other.timer
systemctl status pe_databases-*.timer
Puppet Master Server Restore Guide
1. Stop Database Timers
systemctl stop pe_databases-*.timer
2. Uninstall PE on the Restore Target
sudo /opt/puppetlabs/bin/puppet-enterprise-uninstaller -p -d
Ensure data under /opt/puppetlabs/
and /etc/puppetlabs/
is removed.
3. Reinstall Puppet Enterprise
Install the same version of PE used for backup.
sudo ./puppet-enterprise-installer
4. Restore Backup
On your primary server, run the puppet-backup restore command to restore your PE infrastructure. The default command is:
export TMPDIR=/opt/puppetlabs/restore-backup ## Create directory under filesystem which has sufficient space
sudo puppet-backup restore <BACKUP-FILENAME>
5. Restore Secret Keys
- Orchestrator:
/etc/puppetlabs/orchestration-services/conf.d/secrets/
- LDAP:
/etc/puppetlabs/console-services/conf.d/secrets/keys.json
chown pe-orchestration-services:pe-orchestration-services /path/to/orchestration/keys
chown pe-console-services:pe-console-services /path/to/ldap/keys.json
6. Restart Services
systemctl restart pe-orchestration-services pe-console-services
7. Apply Puppet Configuration
puppet agent -t --no-use_cached_catalog
Run the above command twice.
It does NOT use the last cached catalog from /opt/puppetlabs/puppet/cache/state/
, Instead fetches a fresh catalog from the Puppet Server
8. Validate Agent Connectivity
puppet agent -t --no-use_cached_catalog
9. Handle Replica Removal and Reprovisioning
puppet infrastructure forget --force <REPLICA_CERTNAME>
puppet agent -t
When you restore a Puppet primary server from backup, the restored state might have outdated or missing information about the replica, such as:
- SSL certificates
- RBAC tokens
- CA metadata
- Code sync states
This can cause mismatch or trust issues between the primary and the replica.
10. Uninstall Agent on Replica
/opt/puppetlabs/bin/puppet-enterprise-uninstaller
rm -rf /opt/puppetlabs /etc/puppetlabs
11. Validate if puppet RPM is removed.
rpm -qa | grep -i puppet
12. Install the agent on replica node
curl -k https://<primary_server>:8140/packages/current/install.bash | sudo bash
puppet agent -t
13. On the primary server, as the root user, run
puppet infrastructure provision replica <REPLICA_NODE_NAME> --enable
This command is used to provision a Puppet Primary Replica node.
Sets up the specified node as a replica of the primary server.
Automatically installs and configures necessary components:
- Puppet Server
- PuppetDB
- Console services
- Syncs code, SSL certificates, and RBAC settings from the primary.
- Registers the replica in the infrastructure topology.
--enable
makes the replica active immediately after provisioning.
14. Run Puppet Job
If you wish to immediately run Puppet on all your agents, you can do so with this command:
puppet job run --no-enforce-environment --query 'nodes {deactivated is null and expired is null}'
Validation Steps
1. Infra Status Check
puppet infra status
Ensure all services are running and syncing correctly.
2. Code Deployment Check
sudo puppet-code deploy --dry-run
If errors occur, check SSH configuration for Git access:
touch ~pe-puppet/.ssh/config
chmod 600 ~pe-puppet/.ssh/config
chown pe-puppet:pe-puppet ~pe-puppet/.ssh/config
cat ~pe-puppet/.ssh/config
host <git-host>
HostName <git-host>
IdentityFile /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa
User puppet-batch
StrictHostKeyChecking no
systemctl restart pe-puppetserver
sudo puppet-code deploy --dry-run
This guide helps maintain a reliable Puppet infrastructure with full backup, restore, and validation steps. Adjust all server names and paths according to your actual environment.
Comments
Post a Comment