Catalog into something "human readable"

82 views
Skip to first unread message

Paul.S...@barcap.com

unread,
Dec 6, 2012, 6:50:56 AM12/6/12
to puppet...@googlegroups.com
Hello,

Is there anyway to parse a catalog generated with something like:-

 puppet master --compile <host> > <hostname>.cat

That looks vaguely human readable. I have tried the "puppet catalog print" face but cannot seem to get it to parse for some reason

# puppet catalog print --catalog /var/tmp/<hostname>.cat
err: undefined method `preferred_run_mode=' for #<Puppet::Util::Settings:0x7fa5ef9d6948>
err: Try 'puppet help catalog print' for usage

This is on a 2.7.16 master BTW

Or indeed anything in the PuppetDB that can pull this and parse it ?

Thanks


R.I.Pienaar

unread,
Dec 6, 2012, 12:52:45 PM12/6/12
to puppet...@googlegroups.com


----- Original Message -----
> From: "Olli...@googlemail.com" <Paul.S...@barcap.com>
> To: puppet...@googlegroups.com
> Sent: Thursday, December 6, 2012 1:50:56 PM
> Subject: [Puppet Users] Catalog into something "human readable"
>
> Hello,
>
> Is there anyway to parse a catalog generated with something like:-
>
> puppet master --compile <host> > <hostname>.cat
>
> That looks vaguely human readable. I have tried the "puppet catalog
> print" face but cannot seem to get it to parse for some reason
>
> # puppet catalog print --catalog /var/tmp/<hostname>.cat
> err: undefined method `preferred_run_mode=' for
> #<Puppet::Util::Settings:0x7fa5ef9d6948>
> err: Try 'puppet help catalog print' for usage
>
> This is on a 2.7.16 master BTW


the print face needs puppet 3.

you can try an older version that was just a script @ https://github.com/ripienaar/puppet-parselocalconfig/tree/5430c173d373052f0cdf764cb30a590ec3e729d1

Deepak Giridharagopal

unread,
Dec 6, 2012, 2:04:24 PM12/6/12
to puppet...@googlegroups.com
On the PuppetDB side, there are two ways off the top of my head (newer versions will pretty-print the output, making it more human-readable JSON). These assume you're on the same machine PuppetDB is on:

* you can issue a query for all resources for <hostname>, like so:

curl -G -H "Accept: application/json" 'http://localhost:8080/resources' --data-urlencode 'query=["=", ["node", "name"], "<hostname>"]'

Note that you won't get dependency or containment edges here, but you will get all parameters for all resources for the host. This is much easier with the changes in the PuppetDB master branch (hasn't been released yet, but figured i'd mention it), which lets you just hit /v2/nodes/<hostname>/resources to get all of them without requiring a query.

* you can use the experimental "catalog" endpoint:

curl -v -H 'Accept: application/json' 'http://localhost:8080/experimental/catalog/<hostname>'

That will give you all dependency edges, all containment edges, and all resources + parameters.

deepak
Reply all
Reply to author
Forward
0 new messages