Apply service assign where "array"

Hi,

We are having a lot of apply service based on “host” variable BUT in some case we would like to apply them based on an array!

  vars.systemd["nginx"] = { friendly_name = "nGinx", restart = true, no_enable = true }
  vars.systemd["apache2"] = { friendly_name = "Apache Webserver", restart = true, no_enable = true }
  vars.systemd["varnish"] = { friendly_name = "Varnish Cache", restart = true }
  vars.systemd["memcached"] = { friendly_name = "memcache", restart = true }
  vars.systemd["cron"] = { friendly_name = "Cron Service", restart = false }
  vars.systemd["php7.3-fpm"] = { friendly_name = "php7.3 FPM", restart = false }
  vars.systemd["php7.4-fpm"] = { friendly_name = "php7.4 FPM", restart = false }
  vars.systemd["php8.0-fpm"] = { friendly_name = "php8.0 FPM", restart = false }
  vars.systemd["php8.1-fpm"] = { friendly_name = "php8.1 FPM", restart = false }

Instead of having to define another variable like

vars.nginx = true

Is there a way to do an apply Service with something like

assign where host.vars.systemd["nginx"]

EDIT:
Or maybe the answer is in

assign where host.vars.os == "Linux" && host.vars.systemd != null

and I need to modify this line:

apply Service for (service_name => config in host.vars.systemd) {

You can apply services using an array with a for loop.

apply Service "windows_service" for (service in host.vars.services) {

  name = "Service_" + service
  vars.service_win_service = service
  check_command = "service-windows"

  assign where host.vars.OS == "Windows" && "" !in host.vars.services
}

object Host "myhost" {

  display_name = "myhost"
  address = "10.10.3.4"
 
  vars.services = [ "servicetocheck1", "servicetocheck2" ]
}

Regards 
Alex

@aclark6996

I think my first post was not very clear…

Right now we are using all the vars.systemd array for creating multiple service for the systemd check BUT,

we also need to have some other service added for let say, nginx and apache, and I would like to simplify my host.variables to re-use the the same systemd array.

Right now we have:

apply Service for (service_name => config in host.vars.systemd) {
   
...

  assign where host.vars.os == "Linux" && host.vars.systemd != null
}

And I have:

apply Service "Service [nGinx]" {
  
...
  assign where host.vars.os == "Linux" && host.vars.nginx == true
}

but I would like to remove the host.vars.nginx and re-use the systemd array but JUST for this service…
something like

assign where host.vars.os == "Linux" && host.vars.systemd.name == "nginx"