Unknown function hiera

3,951 views
Skip to first unread message

Andreas Paul

unread,
Apr 4, 2012, 11:26:45 AM4/4/12
to puppet...@googlegroups.com
Hi there,

for some reason I can't use hiera functions in my manifests.
Here are the relevant config files:

cat /etc/puppet/hiera.yaml
:hierarchy:
    - %{environment}
    - common
:backends:
    - yaml
    - puppet
:yaml:
    :datadir: '/etc/puppet/environments/%{environment}/hieradata'
:puppet:
    :datasource: data


cat environments/dev/hieradata/dev.yaml
---
workers   : - '10.125.127.88'

cat environments/dev/modules/intra3/manifests/wsp.pp
class intra3::wsp {

  #$workers = [ '12.3.4.5' ]
  #$workers = $intra3::data::workers
  $workers = hiera('workers')

  wsp::cfg { "tc6_foobar":
    remove => false,
    vhostname => 'test-foobar',
    worker => $workers,
    portrange => 121,
    prodlevel => 7,
    wwwdir => '/www/foobar.enbw.net',
  }

pluginsync is enabled on master and client.
The client picks up changes in the hiera module /lib:

touch dev/modules/hiera/lib/bla.rb

results in:

notice: Ignoring --listen on onetime run
info: Retrieving plugin
notice: /File[/var/lib/puppet/lib/bla.rb]/ensure: defined content as '{md5}d41d8cd98f00b204e9800998ecf8427e'
info: Loading downloaded plugin /var/lib/puppet/lib/bla.rb
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Unknown function hiera at /etc/puppet/environments/dev/modules/intra3/manifests/wsp.pp:5 on node

puppet-2.7.12

gem list hiera
hiera (0.3.0)
hiera-puppet (0.3.0)


Any ideas?

Martin Willemsma

unread,
Apr 4, 2012, 12:10:44 PM4/4/12
to puppet...@googlegroups.com
Hi Andreas,

In my believe that message is from your puppetmaster unable to compile
the manifest because the hiera function is not present on the master.
If you install hiera gem, the functions are not copied to your puppet
functions dir.

I would recommend checking your gem path on the puppetmaster and
confirm the files are present.

> gem env

...
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
...


ls /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/*hier*

Should list: -

/usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_array.rb
/usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_include.rb
/usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_hash.rb
/usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera.rb

On my setup I was able to fix this my manually copying the file to the
puppet libdir:

# copy libs from hiera to puppet
cp /usr/lib/ruby/gems/1.8/gems/hiera-puppet-0.3.0/lib/puppet/parser/functions/*
/usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions

# restart your puppetmaster - if running behind passenger

For me restarting apache was enough

/etc/init.d/apache restart


---
Kind regards,

Martin Willemsma

2012/4/4 Andreas Paul <xor...@googlemail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/BcTVaGLa3s4J.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

--

Nan Liu

unread,
Apr 4, 2012, 12:17:41 PM4/4/12
to puppet...@googlegroups.com
On Wed, Apr 4, 2012 at 9:10 AM, Martin Willemsma <mwill...@gmail.com> wrote:
> Hi Andreas,
>
> In my believe that message is from your puppetmaster unable to compile
> the manifest because the hiera function is not present on the master.
> If you install hiera gem, the functions are not copied to your puppet
> functions dir.

That's correct. Per https://github.com/puppetlabs/hiera-puppet:

"For the moment the Gem install will place the Puppet Parser Function
where Puppet cannot find it, you should copy it out and distribute it
to your master using Pluginsync or something similar"

> I would recommend checking your gem path on the puppetmaster and
> confirm the files are present.
>
>> gem env
>
> ...
>  - GEM PATHS:
>     - /usr/lib/ruby/gems/1.8
>     - /root/.gem/ruby/1.8
> ...
>
>
> ls  /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/*hier*
>
> Should list: -
>
> /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_array.rb
> /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_include.rb
> /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera_hash.rb
> /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions/hiera.rb
>
> On my setup I was able to fix this my manually copying the file to the
> puppet libdir:
>
> # copy libs from hiera to puppet
> cp /usr/lib/ruby/gems/1.8/gems/hiera-puppet-0.3.0/lib/puppet/parser/functions/*
> /usr/lib/ruby/gems/1.8/gems/puppet-2.7.12/lib/puppet/parser/functions

However, I would recommend using puppet module path and puppet
pluginsync rather than copying the files to puppet's gem path. If your
module path is /etc/puppet/modules, the following command should get
the function in a location where puppet can find and compile:

ln -s /usr/lib/ruby/gems/1.8/gems/hiera-puppet-0.3.0
/etc/puppet/modules/hiera-puppet

If you want to check out the lastest version of hiera:

git clone git://github.com/puppetlabs/hiera-puppet.git
/etc/puppet/modules/hiera-puppet

HTH,

Nan

Patrick Debois

unread,
Apr 4, 2012, 12:31:40 PM4/4/12
to puppet...@googlegroups.com
FWIW I've submitted this patch today to:

- include the gem inside the manifest
- load the correct loadpaths
- enable relocatable hiera_configdir and hiera_yaml_datasource

https://github.com/puppetlabs/hiera-puppet/pull/20

This makes it much easier to have things configured until all the hiera
is part of Telly.

Andreas Paul

unread,
Apr 10, 2012, 9:34:35 AM4/10/12
to puppet...@googlegroups.com
The problem was that I thought github.com/puppetlabs/hiera was the hiera puppet module.
It worked after I copied the correct puppet module github.com/puppetlabs/hiera-puppet to the modules folder.
Reply all
Reply to author
Forward
0 new messages