Fix host pattern matching and enhance error detection

Fixes #8614
Use match() instead of search() for pattern matching

Also related to f48fa3, fix for #8614
Load group_vars for new groups loaded via add_host

Fixes #8605
Catch error in atomic_move when creating temporary file

Fixes #8480