Apply rules using NodeName and endpoints in multiple zones

I’m attempting to use apply rules to cover endpoints that have similar attributes, such as disks.

In my master zone, I have an endpoint configured like this:

object Host NodeName {
  import "generic-hostalive-5min"
  address = "127.0.0.1"
  vars.os = "Linux"
  vars.disks["disk"] = {
  **}**
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }

If I attempt to use this for an endpoint in the satellite zone, I get errors because of the duplicate NodeName. In the satellite zone, using this as an endpoint config does not work with the above in the master zone.

object Host NodeName {
  import "generic-hostalive-5min"
  address = "128.0.0.2"
  vars.os = "Linux"
  vars.disks["disk"] = {
  }
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }
}

The goal is to have apply something like this in the global config, which does work with a single host with the host name NodeName:

apply Service for (disk => config in host.vars.disks){
  import "generic-service"
  check_command = "disk"
  vars += config
  assign where host.name == NodeName && host.vars.os == "Linux"
}

Am I mis-understanding the use of constants defined on the endpoints?

This is not possible because NodeName is a constant at your master, hence, object Host NodeName will always be rendered identical and you’ll duplicate error(s).

You could simply remove the assign rule because those service objects are only generated if a host does have vars.disks defined.

Every node has a NodeName constant declared, but I see what you are saying, it’s a bit deeper into the internal operations than I had knowledge.
When using host.vars.disks I was getting command endpoint errors so I dug a bit more and found a solution:

apply Service for (disk => config in host.vars.disks) {
  import "generic-service"
  check_command = "disk"
  command_endpoint = host.name
  vars += config
  assign where host.vars.disks && host.vars.os == "Linux"
}