Your example would be assign where host.name == "sql" && host.name != "somesqlserver"
Once you have some experience setting up those assign rules it gets easier.
You can combine multiple layers of concatenations under one “root” operand and then get crazy
I think the most important piece of info you have to keep in mind is that the operand on top of the indented block is the one that connects all conditions on that level.
Each new level of indentation can be seen as a logical block of conditions - evaluated by applying the operand above between all of them.
This sounds a bit confusing but is actually simple and it helps (at least me) to read the conditions in blocks. Then you can get crazy about it as @log1c already said.
But, at the same time, don’t hesitate to make a step back and review the logic of your service or host vars for example if you find yourself with real complex assignment rules. This might be an indicator that you should simplify the host or service configuration and make your life easier.
Adding a “sublevel” operator is done via the >> button
Tbh I’m surprised that host.name == "hostname1" && host.name == "hostname2" works.
Imo this should not work, because you don’t have a host object that has both names. Or am I just thinking false about the condition?
I’m still not getting it. Would you mind sending a screenshot of the entire condition set of a working one where the service applies to hostname1 and hostname2 but not hostname3?
Due to the AND this means that both sides of the condition have to be true.
This is the case when the hostname is either hostname1ORhostname2 while it must not be hostname3