Ask Your Question
11

How can I purge exported resources from PuppetDB?

asked 2012-12-19 03:16:01 -0500

example42 gravatar image

updated 2013-01-03 12:25:14 -0500

llowder gravatar image

Generally if you need to remove the saved references to exported resources stored on Puppet DB you just need to run, on the puppet master:

    puppet node deactivate <nodename>

There are cases, anyway, when this is does not work correctly, so what can you do to fix it?

edit retag flag offensive close merge delete

5 Answers

Sort by » oldest newest most voted
9

answered 2012-12-19 03:16:36 -0500

example42 gravatar image

updated 2013-01-03 12:27:56 -0500

llowder gravatar image

This is well discussed in ticket 17680

In the thread a solution is given by Mark Front (so credits to him):

I have found a query that allows me to help clear this situation out with 100% reliability: delete from catalogs where hash in (select catalog from catalog_resources where title like ‘%localhost%’); delete from catalogs where hash in (select catalog from catalog_resources where title like ‘%nyops01%’);

So basically if

    puppet node deactivate <nodename> (on the PuppetMaster)

doesn't work, you can go on your PuppetDB server and type:

    su - postgres (or whatever user PostGreSQL runs with)
    psql -d puppetdb -c ...
(more)
edit flag offensive delete link more

Comments

Also note that the "puppet node clean" command is probably the best way to handle this in the longer-term. There is a bug documented in ticket 14721 that is preventing ...(more)

cprice404 gravatar imagecprice404 ( 2013-01-07 14:21:05 -0500 )edit

The table or column names seem to have changed (I'm running puppet 3.7.4).This worked for me: delete from catalogs where id in (select catalog_id from catalog_resources where title like '%somecertname%');

banjer gravatar imagebanjer ( 2015-04-13 10:04:46 -0500 )edit
8

answered 2013-02-05 18:32:11 -0500

feystorm gravatar image

Came up with an alternative solution to this issue. It's similar in spirit to example42's SQL answer, but it's cleaner.

delete from catalogs where hash in (select catalog from certname_catalogs, certnames where certnames.name = certname_catalogs.certname and certnames.deactivated is not null);

or for command line, something like:

sudo -u postgres psql puppetdb -c 'delete from catalogs where hash in (select catalog from certname_catalogs, certnames where certnames.name = certname_catalogs.certname and certnames.deactivated is not null);'

This query will find all the nodes which have been deactivated, and then delete their catalogs.

The reason I didn't ... (more)

edit flag offensive delete link more
1

answered 2014-04-23 07:20:07 -0500

arjarj gravatar image

updated 2014-04-23 07:20:39 -0500

As of puppetdb 1.6.0 the schema changed due to https://tickets.puppetlabs.com/browse/PDB-69. It looks like

delete from catalogs where certname in (select name from certnames where deactivated is not null);

does the trick now.

edit flag offensive delete link more
0

answered 2016-03-21 18:01:27 -0500

how can we activate a node which has been deactivated previously?

edit flag offensive delete link more
0

answered 2016-08-23 19:02:23 -0500

binford2k gravatar image

@sairam run puppet.

Any Puppet run will mark a node as active in PuppetDB, even if you'd previously deactivated it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

5 followers

Stats

Asked: 2012-12-19 03:16:01 -0500

Seen: 18,772 times

Last updated: Aug 23 '16