Skip to content

Instantly share code, notes, and snippets.

View kbarber's full-sized avatar

Ken Barber kbarber

View GitHub Profile
\#\!ipxe
set base-url http://stable.release.core-os.net/amd64-usr/current
kernel ${base-url}/coreos\_production\_pxe.vmlinuz initrd=coreos\_production\_pxe\_image.cpio.gz coreos.first\_boot=1 coreos.config.url=https://example.com/pxe-config.ign
initrd ${base-url}/coreos\_production\_pxe\_image.cpio.gz
boot
Branch pdb-809 (master basically) with 1 node of facts:
Expanded display is used automatically.
Timing is on.
Null display is "<<NULL>>".
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=689.44..711.69 rows=72 width=730) (actual time=3.193..3.810 rows=102 loops=1)
Hash Cond: (fs.certname = certnames.name)
lein test :only com.puppetlabs.puppetdb.test.http.facts/factset-queries
FAIL in (factset-queries) (facts.clj:892)
Testing version :v4 factset queries should return appropriate results
expected: (= (into {} (first responses)) {"facts" {"my_structured_fact" {"a" 1, "b" 3.14, "c" ["a" "b" "c"], "d" {"n" ""}, "e" "1", "f" nil}, "domain" "testing.com", "uptime_seconds" "4000", "test#~delimiter" "foo"}, "timestamp" (to-string current-time), "environment" "DEV", "certname" "foo1"})
actual: (not (= {"facts" {"test#~delimiter" "foo", "uptime_seconds" "4000", "domain" "testing.com", "my_structured_fact" {"b" 3.14, "a" 1, "e" "1", "d" {"n" ""}, "f" nil, "c" ["a" "b" "c"]}}, "timestamp" "2014-07-31T23:27:45.298Z", "environment" "DEV", "certname" "foo1"} {"facts" {"uptime_seconds" "4000", "domain" "testing.com", "test#~delimiter" "foo", "my_structured_fact" {"d" {"n" ""}, "f" nil, "e" "1", "a" 1, "b" 3.14, "c" ["a" "b" "c"]}}, "timestamp" "2014-07-31T23:27:45.297Z", "environment" "DEV", "certname" "foo1"}))
lein test :o
# curl -G 'http://localhost:8080/v4/factsets' --data-urlencode 'query=["in", "certname", ["extract", "certname", ["select-facts", ["and", ["=", "name", "operatingsystem"], ["=", "value", "Darwin"]]]]]'
[ {
"facts" : {
"ipaddress_en2" : "192.168.1.65",
"kernel" : "Darwin",
"macaddress_bridge0" : "42:6c:8f:c1:8e:00",
"kernelrelease" : "13.3.0",
"network_vmnet8" : "192.168.182.0",
"is_pe" : false,
"sp_serial_number" : "C02K50H1DKQ5",
# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: File[/tmp/foo] { require => Package[foobar1] }, because Package[foobar1] doesn't seem to be in the catalog
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
root@puppetdb1:/etc/puppet/manifests# curl 'http://localhost:8080/v4/reports'
[ {
"hash" : "24274701699ddee1b538ffb8400d0b17bf911405",
"puppet-version" : "3.6.2",
2014-07-10 18:14:00,049 ERROR [c.p.p.command] [d2a06fe2-64d1-40ff-ab5b-c8c38b2f5f4e] [replace catalog] Retrying after attempt 4, due to: clojure.lang.ExceptionInfo: Value does not match schema: {:producer-timestamp (not (instance? java.lang.String a-java.sql.Timestamp))} {:schema {:name java.lang.String, :version java.lang.String, :environment (maybe java.lang.String), :transaction-uuid (maybe java.lang.String), :producer-timestamp (maybe java.lang.String), :edges (either [{Any Any}] #{{Any Any}}), :resources (either [{Any Any}] {Any {Any Any}})}, :value {:resources ({:tags ["stage"], :type "Stage", :title "main", :parameters {"alias" ["main"], "name" "main"}, :exported false} {:tags ["class" "file"], :file "/Users/ken/.puppet/manifests/site.pp", :type "File", :title "/tmp", :line 1, :parameters {"ensure" "directory"}, :exported false} {:tags ["class"], :type "Class", :title "main", :parameters {"alias" ["main"], "name" "main"}, :exported false} {:tags ["class" "file"], :file "/Users/ken/.puppet/manifests/sit
# curl 'http://localhost:8080/v4/nodes?query=\["=","certname","puppetdb1.vm"\]'
[ {
"deactivated" : null,
"report-environment" : "production",
"certname" : "puppetdb1.vm",
"facts-timestamp" : "2014-07-05T18:50:19.413Z",
"facts-environment" : "production",
"catalog-timestamp" : "2014-07-05T13:32:33.554Z",
"report-timestamp" : "2014-07-05T18:50:18.633Z",
"catalog-environment" : "production"
diff --git a/puppet/lib/puppet/indirector/catalog/puppetdb.rb b/puppet/lib/puppet/indirector/catalog/puppetdb.rb
index 6bcb50a..7202539 100644
--- a/puppet/lib/puppet/indirector/catalog/puppetdb.rb
+++ b/puppet/lib/puppet/indirector/catalog/puppetdb.rb
@@ -12,6 +12,8 @@ class Puppet::Resource::Catalog::Puppetdb < Puppet::Indirector::REST
end
def save(request)
+ require 'pp'
+ Puppet.warning(request.instance.pretty_inspect)
inet6 sets RES_USE_INET6 in _res.options. This has the
effect of trying a AAAA query before an A query inside
the gethostbyname(3) function, and of mapping IPv4
responses in IPv6 "tunneled form" if no AAAA records
are found but an A record set exists.
[ken@kb puppetdb]# PGDATA=~/Library/Application\ Support/Postgres93/var/ pg_ctl status
pg_ctl: server is running (PID: 73637)
/Applications/Postgres.app/Contents/Versions/9.3/bin/postgres
ruby-1.9.3-p547@puppetdb (git)-[1.6.x]
[ken@kb puppetdb]# curl 'http://localhost:8080/v3/facts/facterversion'
[ {
"certname" : "anawdlxglhmtoaxywidwginvgyeeqwcslixvmerweuzsefktyk",
"name" : "facterversion",
"value" : "1.7.3"
} ]% ruby-1.9.3-p547@puppetdb (git)-[1.6.x]