Icinga Director x509, import automation, modifiers and exceptions with filter expressions

Hello @all,

Unfortunately, I couldn’t think of anything better for the subject :slight_smile:

I currently have the following problem. I want to import x509 hosts via the Icinga Web 2 module and have set up a corresponding automation in the Director:

This works so far. However, I would like to create an exception for some hosts so that the hostname isn’t converted to lowercase for them. Can I somehow influence this using filter rules? I’m asking, especially because I haven’t been able to do this using any rule I know of (object_name, icinga_host, host, address, etc.):

In the example above it would be a matter of setting an exception for hosts such as ms-xc2022A.example.com and ms-xc2022B.example.com to prevent a conversion to ms-xc2022a.example.com and ms-xc2022b.example.com.

With negation, it also seems to make no difference whether I apply it only to the expression itself (host!=<HOSTNAME>) or to the entire expression (!(host=<HOSTNAME>)).

I haven’t been able to find much on this topic in my internet research or here in the community. Does anyone have any ideas or can point me in the right direction? Does this even work the way I intended?

We currently use the following versions:

  • Icinga 2: 2.14.5
  • Icinga Web 2 Version: 2.12.2
  • Director: 1.11.3
  • X509: 1.3.2

goto preview first
there you can see all the properties that are available for querying:

as you can see there is no column named host but on named host_name so your filter can be:

host_name!=ms-xc2022*

and then you can check the preview to see the changes.

The help text is very generic because different importsources can provide different data.

Best Regards
Nicolas

Hi Nicolas,

thanks for your answer and the clues.

I’ve got the following columns at the import source:
grafik

However, the example systems are always converted to lowercase. It doesn’t matter whether I set the filter to host_name_or_ip, host_name or simply host_address or host_ip. The filter is ignored every time.

Best regards
Torsten

can you post a new screenshot of your filter?

Hi Nicolas,

yes, of course.

The import source itself:

And the filter:

Best regards
Torsten

these are not director hosts these are x509 hosts.
can you remove the the filter and check the preview again, the might all be lowercase anyway.

so what you might need is a propertymodifier that uppercases your hostname.
like split/regexsplit in combination with first uppercase.

2 Likes

Hi Nicolas,

Hmm, the longer I think about it, the more logical your suggestion becomes! Especially the more I think about how this import works and what its purpose is :slight_smile:

I’ll experiment with it a bit in the next few days and (hopefully) get back to you with a final answer.

Thanks so much for everything so far.

Best regards,
Torsten

1 Like

Hi Nicolas,

After a bit of experimenting, I’ve now solved my problem by using “Regular Expression Based Replacement” as a modifier and making the necessary adjustments for both host_name_or_ip and host_name.

There was still a bit more work to be done on my side, as otherwise the endpoint and zone names would have been automatically adjusted for the client, which would have caused other problems.

Best regards
Torsten

1 Like