Combining imports – values as an array?

Hi folks,

okay, my question is presumably weird :wink: And I can’t provide really good screenshots as the information is too internal. But I’ll try to explain what I need and I hope someone can understand.

I defined an import source: it pulls many many information from my PuppetDB. It modifies, it syncs, it does magic and creates hosts with attributes and that’s really nice.

One of this hosts is (on of the) webserver(s). This host should get a host variable domains_webhosting_intern which contains an array of all domains this host is responsible for; based on that information I’ll do checks like apply Service "Website => " for (tld in host.vars.domains_webhosting_intern). That’s my goal, and I don’t want to do it manually as it changes very often. So when a new domain is created, it should go as soon as possible into this array of domains; the according check will automatically appear. To realize this, I defined a second import: it connects a MySQL and retrieves all domains, and I can run this as a job and it’s working.

I even can sync these entries to a datalist which is working, too. I can assign this datalist to the domains_webhosting_intern variable and assign that to my host, but then I have to choose the domains by hand.

What’s the right way to automate the assignment domains_webhosting_intern will contain all these domains as an array? I tried several things via sync rules, but it does not work – without any comment, there are no error messages, no alerts.

I tried with datalist and without datalist and so on. As my approach seems kind of weird my question is: how to achive this? Couldn’t be that hard, could it? :thinking:

Using director-1.6.0, icinga2-2.10.2, icingaweb2-2.6.2

Many thanks for reading (and for every idea),
Marianne

Maybe write a helper script to create a CSV with

FQDN_of_webserver;[ARRAY of VHosts]

and import that with the fileshipper module and add that to your host?

Why do you not create the services via sync instead using Icinga’s apply loop logic?

1 Like

To elaborate my reason a bit more: Director can not join multi-row data, such thing must be done in the source, or query.

Datalist is of course a different topic, because we add single data items. But for Director a Array variable is just a single value (JSON serialized internally)

1 Like

Aaaaaah, that’s it! :sunglasses: I got it.

It’s due to historical reasons that I was working with icinga’s apply logic :wink: Meanwhile it’s not only possible to create services via sync, but also to disable them selectively.

I modified my SQL statements with INNER JOIN and was able this way to fit my needs: now I have a service for each website, and the person who’s responsible for this website will get notified. Great.

Thank you very much :green_heart:

2 Likes

You’re welcome. Btw. you can mark a specific post that solves your question.

1 Like

Seems I’m too oldschool… will do it next time.