hiera scope and hiera-foreman

277 views
Skip to first unread message

Christian McHugh

unread,
Aug 9, 2012, 7:57:54 PM8/9/12
to puppet...@googlegroups.com
Hey all,

I've been messing around with the hiera-foreman backend to see if it would let me migrate to hiera and use foreman and an ENC. 

It works by querying each node's yaml file from foreman. Currently this code works when called from the hiera command line with the -m (mcollective option). It uses the mcollective facts to pull the fqdn variable to know which node to grab the yaml for. So far so good. However, this breaks when you attempt to use it as a hiera backend in a puppet module, since it no longer has the mcollective facts, and fqdn available to it. 

So my question is, what is the recommended way of querying the current hostname(s) in a hiera backend for it to know what host it should lookup the needed yaml? 

Thanks!

Christian McHugh

unread,
Aug 10, 2012, 1:23:16 PM8/10/12
to puppet...@googlegroups.com
Okay. I figured out my issue. 

I'm not a developer so this is probably ugly, but came up with:
        begin
          fqdn = scope.catalog.tags[4]
        rescue
          fqdn = scope['fqdn'] if scope.has_key?('fqdn')
          Hiera.debug("trying mcollective")
        end
        Hiera.debug("got fqdn #{fqdn}")

That fqdn with both:
puppet master --debug --compile FQDN
and
hiera -d -c /etc/puppet/hiera.yaml -m FQDN
Reply all
Reply to author
Forward
0 new messages