Nested for loops in Apply Service

Hello I’m having trouble to use multple for statements applying service. For each key in dict ‘custom’ i want to iterate for each value in array.

object Host "host1" {
  vars.custom = {
    "name1" = ["1234","5678"],
    "name2" = ["3245","6542"]
  }
}

After iteration each service should look like this

 Service "some-service-" ...{
  vars.param1 = name1
  vars.param2 = "1234"
}

 Service "some-service-" ...{
  vars.param1 = name1
  vars.param2 = "5678"
}
...
 Service "some-service-" ...{
  vars.param1 = name2
  vars.param2 = "3245"
}

Hello Mamyk!

Unfortunately the apply Service "" for ... construct doesn’t support multiple levels of looping.

You have to iterate nestedly over your custom vars just below their creation inside object Host "" { /* HERE */ } and create a flat array/dict of the desired combinations.

Then your apply-for rule can iterate over that flat aggregate.

Best,
A/K