Recover a database-backed CA
When using database-backed CA storage, recovery depends on both:
-
The
pe-cadatabase -
The passphrase file
Recovery scenarios
| Scenario | Recoverable |
| Database lost, passphrase intact | Yes |
| Passphrase lost, no backup | No |
| Both lost, backup exists | Yes |
| Both lost, no backup | No |
Restore from backup
/opt/puppetlabs/bin/puppet-backup restore --force <backup>.tgz systemctl start pe-puppetserver
If passphrase is lost
-
Restore it from backup if available
-
If not:
-
The CA must be rebuilt
-
All agents must re-enroll
-
Reset the certificate authority as a last resort
Follow these steps only if recovery is not possible:
root on the primary node.-
Create a backup before proceeding.
/opt/puppetlabs/bin/puppet-backup create --force --dir=/tmp --name=pre-reset.tgz
-
Switch the CA to the filesystem backend.
Run the CA storage export plan to export the certificate authority from the database and switch the CA to the filesystem backend.
BOLT_DISABLE_ANALYTICS=true BOLT_GEM=true /opt/puppetlabs/installer/bin/bolt \ --project /opt/puppetlabs/installer/share/Boltdir \ plan run puppet_enterprise::ca_storage_export targets=localhost
-
Copy the classification change into
user_data.conf.a) Run the following command to update
user_data.confand ensure that the CA backend configuration matches the classification setting.puppet infrastructure recover_configuration --pe-environment production
b) Verify that the CA storage backend is set to filesystem:
grep ca_storage_backend /etc/puppetlabs/enterprise/conf.d/user_data.conf
Expected output:
filesystem
-
Rebuild the certificate authority.
Create a new certificate authority and new infrastructure certificates.
puppet infrastructure run rebuild_certificate_authority
-
Replace the old CA in
pe-cawith the new CA.a) Empty the
pe-catables.Remove the existing CA data from
pe-ca./opt/puppetlabs/bin/puppetserver ca storage --cleanup-db --force
b) Import the new CA into
pe-ca.Import the rebuilt CA, CA keys, and certificates into
pe-ca./opt/puppetlabs/bin/puppetserver ca storage --import --full
c) Switch back to the database backend.
Run the CA storage import plan to switch the CA back to the database backend.
BOLT_DISABLE_ANALYTICS=true BOLT_GEM=true /opt/puppetlabs/installer/bin/bolt \ --project /opt/puppetlabs/installer/share/Boltdir \ plan run puppet_enterprise::ca_storage_import targets=localhost
-
Copy the classification change into
user_data.confagain.a) Run the following command to update
user_data.confand ensure that the CA backend configuration matches the classification setting.puppet infrastructure recover_configuration --pe-environment production
b) Verify that the CA storage backend is set to
database:grep ca_storage_backend /etc/puppetlabs/enterprise/conf.d/user_data.conf
Expected output:
database
-
Re-enroll all agents.
Re-enroll each agent so that it trusts the rebuilt certificate authority.
puppet infrastructure run regenerate_agent_certificate agent=<certname> clean_crl=true \ --use-ssh --user <user> --private-key <key>
If your deployment includes compilers or a replica, regenerate their certificates as well using the appropriate certificate regeneration tasks.
-
Verify that the database-backed CA is active.
a) Verify that the CA is using the database backend:
curl -sSk --cert $(puppet config print hostcert) --key $(puppet config print hostprivkey) \ 'https://localhost:8140/status/v1/services/ca-storage?level=info'
Expected output includes:
"backend": "database"
b) Verify that Puppet runs succeed on the primary node and on all re-enrolled agents:
puppet agent -t