The roles of codoping ions (Li, Ga and Cu) and defects (oxygen vacancy and hydrogen impurity) in magnetic interactions in ZnO:Co systems have been studied systematically using an ab initio method with density functional theory and the standard molecular field model. The results show that where defects are not included in ZnO's lattice carrier mediated magnetism is only achievable in shallow p-type codoping, such as ZnO:Co + Cu. However, in deep p-type codoping (ZnO:Co + Li) and deep n-type codoping (ZnO:Co + Ga), the carriers generally do not induce spontaneous magnetism. It was also found that the oxygen vacancy, due to its deep donor nature, has a minor favoring effect on ferromagnetic ordering among Co ions. The observed ferromagnetism in such systems can be attributed to the interaction of Co ions with unintentional hydrogen contamination rather than codopants or oxygen vacancies.