Now I am trying to do a simple “If node1 alpha is down, don’t check node1 beta” via Dependencies, for each node across some of the envs.
I can set that up just fine, one dependency rule by one, but there’s hundreds of nodes total, so we’d end up with thousands of relations when all is done.
I thought to add a node number as a $service.vars.node$, so then I could create a dependency with a Parent Service envX node$service.vars.node$ alpha assigned where service.name = envX node$service.vars.node$ beta, and while that seems to pass the config check, it does not seem to work.
How do I achieve what I want in a smarter way than bruteforcing everything?
I believe I will also run into a situation where envX is spread across multiple zones, to possibly complicate matters further.
Thanks for posting, this one is quite interesting.
I hope that I got your problem description right. Thus, I came up with the following Dependency, which adds a Service dependency hierarchy from a “beta” to an “alpha” Service, where the “beta” Service name matches a pattern derived from your post.
apply Dependency "alpha-beta-hierachy" to Service {
parent_service_name = service.name.replace("beta", "alpha")
assign where match("env* node* beta", service.name)
}
In my test setup, I created a few hosts following the suggested naming schema, and the inspected Dependency objects[1] looked quite right.
Please note that the String#replace function can become a footgun, e.g., when “beta” is part of your hostname. Consider stripping the last four chars and adding “alpha” afterwards - but this was enough for a PoC.
I am not quite sure which role “gamma” plays here, but if it should be a dependent of “beta”, just duplicate the Dependency example and switch names.
This makes things a bit spicy as objects are part of a zone. With no intention to sound rude, but then maybe reconsider your object placement within the zones.
Unfortunately, I am not fluent in the Director. But have you tried setting the value without the surrounding quotes and without escaping the inner quotes, as this is something to be expressed in Icinga 2 DSL?
Otherwise, maybe someone more familiar with the Director might step in.
Otherwise, maybe someone more familiar with the Director might step in.
Im not totally sure on how or whether i could use these Icinga DSL Functions in the Director. Ofc, you could use the Directors Import Source/Sync Rule Features to work with such things.