Skip to content

Instantly share code, notes, and snippets.

root@puppetdb1:~# cat query.json
["and",
["in","certname",
["extract","certname",
["select-facts",
["and",
["=","name","kernel"],
["=","value","Linux"]]]]],
["or",
["=","name","hostname"],
[ken@kb puppetdb-vagrant]# vagrant ssh ubuntu-13.10-64-nocm
Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-12-generic x86_64)
* Documentation: https://help.ubuntu.com/
$ sudo -i
root@localhost:~# wget 'https://apt.puppetlabs.com/puppetlabs-release-saucy.deb'
--2014-04-30 07:54:03-- https://apt.puppetlabs.com/puppetlabs-release-saucy.deb
Resolving apt.puppetlabs.com (apt.puppetlabs.com)... 198.58.114.168, 2600:3c00::f03c:91ff:fe69:6bf0
Connecting to apt.puppetlabs.com (apt.puppetlabs.com)|198.58.114.168|:443... connected.
HTTP request sent, awaiting response... 200 OK
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'pp'
def store_report(report)
uri = URI.parse("http://localhost:8080/v3/commands")
root@puppetdb1:~# curl 'http://localhost:8080/v3/reports?query=\["=","certname","puppetdb1.vm"\]'
[ {
"end-time" : "2014-04-27T02:11:11.071Z",
"certname" : "puppetdb1.vm",
"hash" : "6b5d999e5f8d24e28f192b06678af01f231d32de",
"report-format" : 4,
"start-time" : "2014-04-27T02:11:10.564Z",
"puppet-version" : "3.5.0-rc2",
"configuration-version" : "1398361105",
"transaction-uuid" : "6ca7f76d-1f8c-4c53-8d00-4c4fdd3480ca",
root@puppetdb1:~# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/postgresql/lib/facter/postgres_default_version.rb
Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Info: Loading facts in /etc/puppet/modules/my_template/lib/facter/foo.rb
[ken@kb puppetdb]# psql
psql (9.3.4)
Type "help" for help.
ken=# \c puppetdb
You are now connected to database "puppetdb" as user "ken".
puppetdb=# select * from schema_migrations;
version | time
---------+-------------------------
1 | 2014-04-18 18:15:20.853
[ken@kb puppetdb-tools]# s3cmd ls s3://puppet-vagrant-boxes
DIR s3://puppet-vagrant-boxes/ppm/
2013-06-16 04:26 4 s3://puppet-vagrant-boxes/artifact-2.foo
2013-06-16 21:17 4 s3://puppet-vagrant-boxes/artifact-3.foo
2013-06-16 03:54 4 s3://puppet-vagrant-boxes/artifact.foo
2014-02-18 22:45 287640984 s3://puppet-vagrant-boxes/centos-510-i386-virtualbox-nocm.box
2014-01-23 21:39 289413682 s3://puppet-vagrant-boxes/centos-510-i386-virtualbox-puppet.box
2014-02-18 22:37 355013823 s3://puppet-vagrant-boxes/centos-510-i386-vmware-nocm.box
2014-02-18 22:45 311035063 s3://puppet-vagrant-boxes/centos-510-x64-virtualbox-nocm.box
2014-01-23 21:36 311473621 s3://puppet-vagrant-boxes/centos-510-x64-virtualbox-puppet.box
[ken@kb puppetdb]# RUBYLIB=puppet/lib puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts in /Users/ken/.puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /Users/ken/.puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /Users/ken/.puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /Users/ken/.puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /Users/ken/.puppet/var/lib/facter/facter_dot_d.rb
Info: Loading facts in /Users/ken/.puppet/var/lib/facter/pe_version.rb
Info: Loading facts in /Users/ken/.puppet/var/lib/facter/puppet_vardir.rb
root@puppetdb1:/etc/puppetdb# puppetdb foreground --debug
2014-04-10 18:13:09,650 INFO [puppetlabs.jetty] Removing buggy security provider SunPKCS11-NSS version 1.7
2014-04-10 18:13:16,893 DEBUG [main] [utils.logging] Debug logging enabled
2014-04-10 18:13:16,953 DEBUG [main] [kitchensink.ssl] Loaded PEM object of type 'class org.bouncycastle.jcajce.provider.asymmetric.x509.X509CertificateObject' from '/etc/puppetdb/ssl/ca.pem'
2014-04-10 18:13:16,970 DEBUG [main] [kitchensink.ssl] Loaded PEM object of type 'class java.security.KeyPair' from '/etc/puppetdb/ssl/private.pem'
2014-04-10 18:13:16,974 DEBUG [main] [kitchensink.ssl] Loaded PEM object of type 'class org.bouncycastle.jcajce.provider.asymmetric.x509.X509CertificateObject' from '/etc/puppetdb/ssl/public.pem'
2014-04-10 18:13:17,108 INFO [main] [cli.services] PuppetDB version 1.6.3
2014-04-10 18:13:17,109 DEBUG [main] [bonecp.BoneCPDataSource] JDBC URL = jdbc:postgresql://pg1.vm:5432/puppetdb, Username = puppetdb, partitions = 1, max (per partition) =