Puppet: How to fix “Unknown function hiera_include”

hierapuppet

I've installed Puppet using the foreman-installer and it installed successfully.

Then, I wanted to install Hiera as I have some modules which use hiera functions so I've installed hiera and created a relevant hiera.yaml file in /etc/puppet which looks like that:

:backends: 
  - yaml 
:yaml: 
  :datadir: '/etc/puppet/hieradata/%{::environment}' 
:hierarchy: 
  - fqdns/%{::fqdn} 
  - roles/%{::role} 
  - domains/%{::domain} 
  - common

In addition, I've created a symbolic link from /etc/puppet/hiera.yaml to /etc/hiera.yaml.

I've also created the required folders to support the hiera hierarchy.

Here's a list of gem packages which are installed on the server:

ansi (1.4.3)
clamp (0.6.2)
facter (2.4.4)
ffi (1.0.9)
foreman_api (0.1.11)
gssapi (1.1.2)
hashie (2.0.5)
hiera (3.0.1, 1.3.4)
hiera-puppet (1.0.0)
highline (1.6.21)
json (1.4.6)
json_pure (1.8.2)
kafo (0.5.4)
kafo_parsers (0.0.2)
little-plugger (1.1.3)
logging (1.8.1)
mime-types (1.16)
multi_json (1.8.2)
netrc (0.7.7)
oauth (0.4.7)
passenger (4.0.18)
powerbar (1.0.11)
rack (1.1.0)
rack-test (0.5.4)
rake (0.8.7)
rdoc (3.12)
rest-client (1.6.7)
rkerberos (0.1.2)
rubyipmi (0.7.0)
sinatra (1.0)

hiera as a command works in the server:

[root@dev5-puppet01 puppet]# hiera role
nil

But when I run: puppet agent -t, I get the following error:

[root@dev5-puppet01 puppet]# puppet agent -t
info: Retrieving plugin
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Unknown function hiera_include at /etc/puppet/manifests/site.pp:2 on node dev5-puppet01.domain.com
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

I've ran locate hiera_include and found it here:

/usr/lib/ruby/gems/1.8/gems/hiera-puppet-1.0.0/lib/puppet/parser/functions/hiera_include.rb

which seems to be the right path for the function.

Puppet's site.pp looks like that:

[root@dev5-puppet01 puppet]# cat /etc/puppet/manifests/site.pp
# Empty site.pp required (puppet #15106, foreman #1708)
hiera_include('classes'

)

Some relevant info:
Puppet version: 2.7.26
Pluginsync is enabled on Puppet server which acts also as it's own client.

So what am I doing wrong? How come the function is not found by Puppet?

Best Answer

It could be possible that you would need to manually copy the function rb file into /usr/lib/ruby/gems/1.8/gems/puppet-${version}/lib/puppet/parser/functions/ however I would highly advise to not run Puppet 2.7.x (Open Source) in a production environment anymore.
It is end of life and will not get updates anymore, see:
http://docs.puppetlabs.com/release_notes/

Currently supported (Open Source) versions are 3.8 and 4.2.