Double-reporting to 2 different instances of Foreman

Hi, all!

I'm trying to set up a double-reporting from my puppet-masters to "local"
instance of Foreman (basically default setup) and to a "remote" Foreman
instance used only for centralized reports and facts storing for
convenience.

So, I made a copy of /usr/share/ruby/vendor_ruby/puppet/reports/foreman.rb
to /usr/share/ruby/vendor_ruby/puppet/reports/remote.rb, modified report
name and config file name(s):

diff foreman.rb remote.rb

4c4
< # configuration is in /etc/puppet/foreman.yaml

··· --- > # configuration is in /etc/puppet/remote.yaml 28c28 < $settings_file = '/usr/local/etc/puppet/foreman.yaml' --- > $settings_file = '/usr/local/etc/puppet/remote.yaml' 30c30 < $settings_file = File.exist?('/etc/puppetlabs/puppet/foreman.yaml') ? '/etc/puppetlabs/puppet/foreman.yaml' : '/etc/puppet/foreman.yaml' --- > $settings_file = File.exist?('/etc/puppetlabs/puppet/remote.yaml') ? '/etc/puppetlabs/puppet/remote.yaml' : '/etc/puppet/remote.yaml' 35,36c35,36 < Puppet::Reports.register_report(:foreman) do < desc "Sends reports directly to Foreman" --- > Puppet::Reports.register_report(:remote) do > desc "Sends reports directly to #{SETTINGS[:url]}"

And added that report name to puppet.conf on my masters:

grep reports /etc/puppet/puppet.conf

reports          = remote, foreman

After restart/reload of Apache, I see that reports are sent to both places,
but only once. Subsequent puppet runs result in reports sent only to
whatever report is specified the last. As in example above, only local
instance would get reports. If I flip to “foreman, remote”, remote is the
one that would have the reports sent to and not a local one.

Other type if reports (log, store) do not exhibit the same issue, so I must
be missing something in remote.rb and it creates a conflict of some sort. I
don’t any errors in logs or anything.

Any clues?
Thanks!

Try renaming the $settings_file variable here, it's a global variable
that will be overwritten between the two report processors. I'd also
rename SETTINGS on the next line.

··· On 28/09/16 23:36, 'Konstantin Orekhov' via Foreman users wrote: > < $settings_file = '/usr/local/etc/puppet/foreman.yaml' > --- >> $settings_file = '/usr/local/etc/puppet/remote.yaml' > 30c30 > < $settings_file = File.exist?('/etc/puppetlabs/puppet/foreman.yaml') > ? '/etc/puppetlabs/puppet/foreman.yaml' : '/etc/puppet/foreman.yaml' > --- >> $settings_file = File.exist?('/etc/puppetlabs/puppet/remote.yaml') ? > '/etc/puppetlabs/puppet/remote.yaml' : '/etc/puppet/remote.yaml'


Dominic Cleal
dominic@cleal.org

Thanks, Dominic!

It turned out to be SETTINGS that needed to be renamed, renaming
$settings_file had no effect.