Using the foreman function

I hate doing this but I've been trying this for a week now and can't seem
to find anything official or basic. So I figured I'd at least create a
thread here.
RHEL 6.5
Puppet 3.4.2
Foreman 1.4.5

I'm using this web page to try to get the foreman function working in my
manifests.

I've updated the 'foreman_url', 'foreman_user' and 'foreman_pass' ( User
and pass are for the API user) in file /var/lib/puppet/lib/foreman.rb.

I'm using this test code in a basic manifest:
$foreman_ipaddr_eth1 = foreman(item => 'hosts', search => 'last_report > "1
week ago" and hostgroup = Clients', per_page => 1000)

And I get this error when I run 'puppet agent -t'
Info: Retrieving plugin
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/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Unknown function foreman at
/etc/puppet/environments/production/modules/customize/manifests/generic/interfaces.pp:7
on node test-43.abc.xyz.edu
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

The comments on the first page point to newer docs at this URL 'newer
updated api docs are at http://theforeman.org/api_v2.html' when someone had
the same error as me but it seems like the API call isn;t the issue it's
that my foureman function can't be found. Can someone help point me in the
right direction?

You need to ensure the function itself is in your modulepath somewhere

  • usually the easiest way is to copy the installer module into the
    path. Obviously it will depend on your paths, but I would run

cp -r /usr/share/foreman-installer/modules/foreman
/etc/puppet/environments/production/modules/

You should also restart the puppetmaster as it caches functions I think.

Greg

Thanks Greg. That did it. I forgot that puppet plugins actually were a part
of a module. Also thanks for your SSH module. I find it very handy.

ยทยทยท On Wednesday, August 13, 2014 5:10:40 AM UTC-4, Greg Sutcliffe wrote: > > You need to ensure the function itself is in your modulepath somewhere > - usually the easiest way is to copy the installer module into the > path. Obviously it will depend on your paths, but I would run > > cp -r /usr/share/foreman-installer/modules/foreman > /etc/puppet/environments/production/modules/ > > You should also restart the puppetmaster as it caches functions I think. > > Greg >