On the generalized Oberwolfach problem