On puppet 2.6 I'm trying to get the compiled catalog for a node in a
script, but I'm having trouble figuring out how to do this with puppet
code and still take the facts into account (the facts live in the
--yamldir by default at /var/lib/puppet/yaml/facts). I'm hoping
someone knows how to do this without having to do a lot of digging,
since if that's what it takes I'll keep digging.
I can find the catalog like so
require 'puppet'
Puppet::Resource::Catalog.find('ubuntu1004desktop.localdomain')
But the catalog this finds doesn't use fact information. I can tell
because if I have a site.pp like this:
node default {
$mynotice = $operatingsystem ? {
Ubuntu => 'ubuntu',
default => 'blah',
}
notify { $mynotice : }
and in irb run
Puppet::Resource::Catalog.find('ubuntu1004desktop.localdomain').vertices.select
{|vertex| vertex.type == "Notify"}.map {|v| v.title}
=> ["blah"]
I know the facts can be accessed by puppet code since I can get the
catalog to compile to pson and use the facts in the yamldir (looks
like yamldir isn't the best name for that option or directory) using
the --compile option:
puppet master --compile ubuntu1004desktop.localdomain
=>
{
"exported": false,
"line": 6,
"title": "ubuntu",
"tags": [
"notify",
"ubuntu",
"node",
"default",
"class"
],
"type": "Notify",
"file": "/etc/puppet/manifests/site.pp"
},
So I thought I traced the code path to see where the facts were
getting loaded and found a couple things that I thought might get the
facts to load properly, but they didn't. Here's a few of the things
I've tried to get the facts loaded.
Puppet::Node.cache_class = :yaml
Puppet::Node::Facts.terminus_class = :facter
Puppet::Node::Facts.cache_class = :yaml
Puppet.parse_config
Probably way more info than anyone needed and thanks in advance if
anyone knows where to look.
Matt
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.