Adding values to arrays in director in template inheritance

Hi,

in terms of nested dictionaries and arrays, the Director provides only a limited set of the Icinga 2 DSL. Which basically means that you need to use flattened values and cannot use advanced techniques shown in the Icinga 2 DSL examples with nested apply for loops and so on.

In terms of the question, let’s see about this - no Director pro, still learning myself. I’m using the Vagrant box standalone which includes Director 1.6.0.

Template Inheritance

  • Define a new data field disks as array

  • Define the host template windows-generic, add disks as field, add C: as values in the template



  • Add host win-sql, import the windows-generic template, and set disks as custom property to E:

  • Deploy the config and render it

Conclusion: Additive assignments for array lists are not supported in the interface.

Service Sets

So, I just sat down and remembered what I’ve tried a while ago with analyzing a problem in Icinga and the Director.

I do think that service sets exactly solve your requirement, but you need to try them out.

Since this got pretty long with many screenshots, I’ve moved it into the howto section. I guess this is one of best strategies inside the Director without much docs :slight_smile:

Director Service Sets: Add service checks based on host templates

Conclusion

Try it out and see if that fits your problem. It requires a little change in your thinking and strategy.
I’ve written this at work, improving my Director skills once more and even getting direct Feedback from Tom.

Cheers,
Michael

3 Likes