Puppetdb

From Wiki
Jump to: navigation, search

Test script.

/usr/bin/env python
from pypuppetdb import connect
import platform

hostname = platform.node()

cert = '/var/lib/puppet/ssl/certs/%s.pem' %hostname
key = '/var/lib/puppet/ssl/private_keys/%s.pem' %hostname
puppetdb_host = 'puppetdb.example.com'

db = connect(host=puppetdb_host, port=8081, ssl_key=key, ssl_cert=cert, ssl_verify=False)

nodes = db.nodes()

for node in nodes:
    print(node)

Terminus files need to be installed in /usr/share/ruby/vendor_ruby/puppet.

git clone git://github.com/puppetlabs/puppetdb
git checkout stable
cp -Rp /usr/share/ruby/vendor_ruby/puppet/ /usr/share/ruby/vendor_ruby/puppet.backup
cd puppet/lib/puppet
rsync -avHl ./ /usr/share/ruby/vendor_ruby/puppet/

Update /etc/puppetlabs/puppet/puppetdb.conf with the proper server name.

[main]
server_urls = https://puppetdb.example.com:8081

Update report settings in puppet.conf.

[master]
    storeconfigs = true
    storeconfigs_backend = puppetdb
    reports = store, puppetdb

Delete facts for a node:

psql -U puppetdb puppetdb
delete from catalog_resources where certname_id = (select id from certnames where certname = 'hostname') ;