Hostgroups and servicegroups based on PuppetDB values via Icinga Director

director

(Marianne Spiller) #1

Hi - it’s me (still alive, but very busy) :slight_smile:

I’m currently working hard to get a Puppet/ PuppetDB/ Foreman/ Icinga2/ Icinga Director Setup ready for production. Creating full automated host configs for Icinga2 based on the PuppetDB datapool works fine (with some restrictions regarding Windows Clients, but that’s another story).

So now a thing that’s not working, but kind of important to me: all by nodes have a custom fact dfki_role; it’s a comma separated list like this: dfki_role=elk_master,icinga_master,webserver. My import modifier in Icinga Director handles this using split with delimiter , (comma) and returns an empty array when empty. In Preview I see: everything works as expected.

Based on this values I`d like to manage my servicegroups; so I’ve created a correcsponding Sync Rule in Icinga Director.

And these are the Properties defined in this Sync Rule:
20

What I expect from a sync run: it should create three servicegroups:

  • object_name elk_master with display_name elk_master
  • object_name icinga_master with display_name icinga_master
  • object_name webserver with display_name webserver

What in fact happens on a sync rule run: it will create a servicegroup for every ${certname} with no display_name at all; exactly the same happens when trying to create hostgroups based on a custom fact.

So my question is: am I raping poor Director for things it isn’t intended to do? Is it a bug? Is anyone else here using it and can help me?

Thank you so much :green_heart:
Marianne


(Carsten Köbke) #2

Hello Marianne,

${dfki_role} should be an array after import. Iam not sure if the director can manage arrays for object_names and display_name.

Best regards,
Carsten


(Marianne Spiller) #3

Hi Carsten,

I also tested with a second field which is not at array but a simple string. Same (or similar?) error…

:frowning:


(Carsten Köbke) #4

Hi Marianne,

can you post a sample of the imported data? i see only dfki_role :slight_smile:


(Nicolai) #5

IMHO it isn’t possible with arrays, unless you have something on the database side like postgresql’s unnest . You have to transform the values into rows, because one row = one object.


(Marianne Spiller) #6

So when I understand you correctly I can sum up like this:

  • Arrays won’t work (so sad!)
  • When I use a custom fact which is a simple string it has to work

As I mentioned above: I have a second fact which represents the hostgroup: no commas, not split, no array magic, but it doesn’t work either… :frowning:


(Nicolai) #7

With a plain string it should work as expected. Keep in mind, that for each line (or certname) an entry is created (and the key column specified in the first importsource is used as object_name):