Ensemble nonequivalence in random graphs with modular structure