Ansible supports pattern to select and filter running hosts from all hosts. Here is some common pattern
*: wildcard, standalone meanallgroup1,group2: run hosts belong to group1 or group2*.web: run hosts belongs to group matches pattern. Ex:backend.web,frontend.weball:!abc: run all hosts exclude hosts belongs to groupabc
Infrastructure by code ;)