host A unreachable so Host B is target ?

hi
i have two hosts and i need to run my playbook only on one of them. i.e host A is always the target, unless it is not reachable. in this case, host B will be the target.
but the point is that if host A is reachable , playbook should’t work on host B.
any advice is accepted.
thanks