We provide the exact non-Markovian master equation for a two-level system interacting with a thermal bosonic bath, and we write the solution of such a master equation in terms of the Bloch vector. We show that previous approximated results are particular limits of our exact master equation. We generalize these results to more complex systems involving an arbitrary number of two-level systems coupled to different thermal baths, providing the exact master equations also for these systems. As an example of this general case we derive the master equation for the Jaynes-Cummings model.