Hostgroups issue when i define the custom attribute

Here my host group file:

/**
 * Host group examples.
 */

object HostGroup "linux-servers" {
  display_name = "On-Prem Linux Servers"

  assign where host.vars.os == "Linux"
}

object HostGroup "windows-servers" {
  display_name = "On-Prem Windows Servers"

  assign where host.vars.os == "Windows"
}

object HostGroup "aws-linux-servers" {
  display_name = "AWS Linux Servers"

  assign where host.vars.os == "AWS-Linux"
}

object HostGroup "aws-windows-servers" {
  display_name = "AWS Windows Servers"

  assign where host.vars.os == "AWS-Windows"
}

Here, My Service config

apply Service "os-version" {
  check_command = "nscp-local-os-version"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint && host.vars.os == "Windows" && host.vars.os == "AWS-Windows"
}

this is not working…I can assign both attributes Windows & AWS-Windows for single service? its only working for one… & its not working for both How can we fix this? Can you please advise someone?

You need to assign to be or and not and

Assign where xxx=yyy || aaa=bbb

Hi,

as @anon66228339 said, chain the logical expression within an OR, following with the AND for the client_endpoint, like this:

assign where host.vars.client_endpoint && (host.vars.os == "Windows" || host.vars.os == "AWS-Windows")

Since you’re using HostGroups already, you could also just check for the host groups being assigned for these hosts. This allows to later modify the hostgroup assignment conditions, without having to touch the service apply rule.

assign where host.vars.client_endpoint && ("windows-servers" in host.groups || "aws-windows-servers" in host.groups)

Cheers,
Michael