theforeman / puppetdb_foreman

PuppetDB proxy in Foreman
http://theforeman.org
GNU General Public License v3.0
32 stars 23 forks source link

puppetDB not interracting with foreman version >=2.2 #70

Closed adriangalbincea closed 3 years ago

adriangalbincea commented 3 years ago

Hi, can this plugin be updated to be able to interact correctly with newer foreman versions?

laugmanuel commented 3 years ago

Hi @adriangalbincea,

where do you experience problems with newer Foreman versions? Can you share a specific problem?

We do use this plugin with Foreman 2.3 and PuppetDB 6.17 and it works fine for me.

Please note, that the plugin is currently only specifically packaged for Foreman 2.1. However, this version is compatible with at least Foreman 2.3:

 root@foreman:~# rpm -qa | grep -iE "(puppetdb|^foreman-2.)"
tfm-rubygem-puppetdb_foreman-5.0.0-2.fm2_1.el7.noarch
foreman-2.3.5-1.el7.noarch
adriangalbincea commented 3 years ago

Hi @laugmanuel

I use ubuntu 18.04.5 I have installed puppetserver 6.16 with puppetdb 6.17 I am currently on Foreman 2.1.4 and if I will try to update to 2.2 and then install puppetdb module, even the module will appear in Foreman, the Icinga collector module will not be able to get data anymore from puppetdb... even the data is present in puppetDB I updated from 1.2 in the last period to 2.1.4 without big problems but now I am stuck.

puppetdb/bionic,bionic,now 6.17.0-1bionic all [installed] puppetdb-termini/bionic,bionic,now 6.17.0-1bionic all [installed] ruby-puppetdb-foreman/plugins 5.0.0-1 all foreman/bionic,now 2.1.4-1 amd64 [installed,automatic]

laugmanuel commented 3 years ago

Hi @adriangalbincea,

so you do have problems with "Icinga collector module" after the update and not with the basic interaction between Foreman and PuppetDB (deleting hosts in PuppetDB, comparing Foreman Hosts against PuppetDB hosts, ...)?

What exactly do you mean with "Icinga collector module"? Do you mean the "Import data source" in Icinga to import data from PuppetDB?

Did you make sure to set the correct version of PuppetDB at all places (Foreman settings, Icinga data source, ...)?

adriangalbincea commented 3 years ago

Hi @laugmanuel

We have a module puppet_icinga2 but is a bit customized so will automatically create hosts and services in Icinga2. That module is a bit old but difficult to update because of the customizations... Not sure what will break the connection to DB after the update. I am tempted to give up... I already spent several hours finding a fix.

The issue is that I am not the person who originally did the config, and this module is the only one I am not confident with...

I think is not managing to read the DB correctly and then is deleting all the hosts from Icinga and throwing this warning too: FileBucket got a duplicate file puppet -> not sure why, anyway on the next run will not add any other hosts and will not throw any other warnings :)

laugmanuel commented 3 years ago

Hi @adriangalbincea ,

this leads me to believe that the puppet_icinga2 module you use is the problem.

Can you try to query the PuppetDB API after upgrading to see if the hosts are still there?

Additionally, you can navigate to Foreman -> PuppetDB Nodes to see if:

  1. Foreman can access the PuppetDB at all (it should list the number of Hosts in PuppetDB there)
  2. Foreman maps the hosts correctly (you should see no orphan hosts in the table)

To be honest, it's difficult for me to imagine what is going on in your environment...

adriangalbincea commented 3 years ago

Hi @laugmanuel

I know, it is difficult. I checked the Nodes and were some differences and I sorted them out, deleted them as were not relevant anymore. Checked before and after the upgrade and they look the same.

I did query the DB and I get data fine.

I think the problem is somewhere else, in the way that module queries the DB, maybe at some point I will get better with SQL as at the moment I am not great :)

I will give my brain a break to put things together and will wait for ideas.

Thanks for you help.

laugmanuel commented 3 years ago

Hi @adriangalbincea,

ok. If the data in Foreman looks identical before and after the upgrade and you also see the desired entries using the PuppetDB API (no need to use SQL here - the API provides ways to query nodes), I suggest looking into the puppet_icinga2 module you use. However, this has nothing to do with this Foreman plugin (puppetdb_foreman) where this Issue resides.

WDYT @timogoebel ?

timogoebel commented 3 years ago

@laugmanuel: I concur. Let's close this here.

Please let us know if anything can be done here, preferably with some kind of error message we can investigate.