Puppet Duplicate Resources with PuppetDB
If you’re using puppet and exported resources and get an error while running the puppet agent showing
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Then you’ve got a duplicate resource in the puppetdb which typically happens when you export resources to be imported else which has already happened, usually because you’ve rebuilt the host and not deactivated it prior
To resolve this you can remove the previous exports from the database. I’ve used a select statement first to check what is returned
su - postgres psql puppetdb > SELECT * FROM catalog_resources WHERE title LIKE = "%Title%"; # DELETE FROM catalog_resources WHERE title LIKE = "%Title%";
Built in PuppetDB (HSQLDB):
systemctl stop puppetdb cd /var/lig/puppetdb/db/ cat -n db.script | grep <Title> sed -i.bak -e '<n>d' db.script systemctl start puppetdb
Please replace <Title> with the title of your export and replace <n> with the line number that is returned from the cat command.
Some of this information is from Chris Cowley and he’s done a better job and writing about it.