Puppet not sending facts to Foreman

Hello,

I'm currently having problems updating Foreman's facts from Puppet. I think
the problem may have started with the update to Puppet 3.4.2 or Foreman
1.3.2.

I am using Puppet 3.4.2 and Foreman 1.3.2, and on Ubuntu 12.04.

From /var/log/foreman/production.log on the Puppet Master (host names and
IP addresses edited):

Started GET "/puppet/node/host.example.com?format=yml" for 127.0.0.1 at Thu
Jan 23 08:59:23 +0000 2014
Processing by HostsController#externalNodes as YML
Parameters: {"name"=>"host.example.com"}
Rendered text template (0.0ms)
Completed 200 OK in 175.1ms (Views: 0.6ms | ActiveRecord: 4.3ms)

So, some part of the communication is working. However, I then get:

Started POST "/puppet/api/hosts/facts" for 127.0.0.1 at Thu Jan 23 08:59:25
+0000 2014
Processing by Api::V2::HostsController#facts as JSON
Parameters: {"name"=>"host.example.com", "certname"=>"host.example.com",
"facts"=>"[FILTERED]", "host"=>{"name"=>"host.example.com", "
certname"=>"host.example.com", "facts"=>"[FILTERED]"}}
wrong number of arguments (4 for 3) (ArgumentError)
/usr/share/foreman/vendor/ruby/1.8/bundler/gems/foreman_default_hostgroup-93ef264fa5c1/lib/default_hostgroup_managed_host_patch.rb:14:in
`importHostAndFacts_
without_apply_hostgroup'

…long Ruby backtrace snipped…

Rendered api/v2/errors/standard_error.json.rabl (0.6ms)
Completed 500 Internal Server Error in 11.6ms (Views: 1.7ms | ActiveRecord:
0.5ms)

I believe I have correctly updated to the latest node.rb and
foreman-report.erb and restarted Foreman in the meantime. I can't seem to
trace the function that is being passed the wrong number of parameters,
either.

Does anyone have any suggestions as to what might be the problem?

Thanks,

Philip

This is the clue - it's the default-hostgroup plugin that's causing the
issue. Looking at the SHA in that error message, you're using the latest
'master' branch, rather than the 1.0.1 gem release (SHA:
8fa9727996672d96fab772d37aa81d9d91fc433d). Could you change to that version
and retest?

Greg

··· On 23 January 2014 09:22, Philip Blakely wrote:

wrong number of arguments (4 for 3) (ArgumentError)
/usr/share/foreman/vendor/ruby/1.8/bundler/gems/foreman_default_hostgroup-93ef264fa5c1/lib/default_hostgroup_managed_host_patch.rb:14:in
`importHostAndFacts_
without_apply_hostgroup’

Hi Greg,

> This is the clue - it's the default-hostgroup plugin that's causing the
> issue. Looking at the SHA in that error message, you're using the latest
> 'master' branch, rather than the 1.0.1 gem release (SHA:
> 8fa9727996672d96fab772d37aa81d9d91fc433d). Could you change to that version
> and retest?
>

Thanks for your reply. A very silly question, how do I do this?

I didn't appear to have foreman_default_hostgroup installed, when I ran
"gem query" .
I have now done "gem install foreman_default_hostgroup" so that gem query
displays it as version 1.0.1. However, no more foreman_default_hostgroup-*
folders seem to have shown up, and I get the same problem, even after
restarting foreman, apache2, and puppet.

Just before you replied, I had managed to fix the problem by removing the
proxy_id parameter and restarting services.

Thanks,

Philip

Grep bundler.d for "default_hostroup" and see if it's been added in there.
Simply installing it via "gem" won't affect how Bundler loads libraries.

Greg

··· On 23 January 2014 10:43, Philip Blakely wrote:

Thanks for your reply. A very silly question, how do I do this?

> Grep bundler.d for "default_hostroup" and see if it's been added in there.
> Simply installing it via "gem" won't affect how Bundler loads libraries.
>

So, Gemfile.local.rb had:
gem 'foreman_default_hostgroup', :git =>
'https://github.com/GregSutcliffe/foreman_default_hostgroup'
which would explain why I was on the latest git version rather than 1.0.1.
I've now made this read
gem 'foreman_default_hostgroup'

but I've now got into a state where I get
/usr/lib/ruby/vendor_ruby/bundler/runtime.rb:74:in `require': no such file
to load – audited/activerecord (LoadError)

when I try to start Foreman.

Thanks,

Philip

Hi Greg,

OK, I've got it working now. I'm not sure how I managed to get bundler into
a confused state, but for the benefit of anyone who gets this or a similar
problem I ended up doing:

Edited /usr/share/foreman/bundler.d/Gemfile.local.rb to remove the svn
reference for foreman_default_hostgroup
cd /usr/share/foreman
mv vendor vendor.old
bundle update
bundle install
chown foreman:foreman -R vendor (very important; I was running as root, so
the files were otherwise hidden to Foreman)
service foreman start

At least I think those were the important steps; I need to go and learn
more about Ruby/Gems/Bundler…

Thanks for your help.

Philip