In this paper, an agent-based model for opinion dynamics on an adaptive coupled random network is proposed. Based on Festinger's idea of "cognitive dissonance", in the proposed model an agent can either make opinion exchange with a neighbor according to the bounded confidence mechanism, or migrate toward another network position in case that the majority of the adjacent agents are beyond the confidence bound. Through numerical simulations, we test how the key factors, such as the interconnectivity of the two communities, the confidence bound or the communal tolerance to diversity, the initial distributions of the opinions, and the level of sense of community, affect the final opinion state of the system. The overall analyses show a general picture of the dynamics of opinions on an adaptive network with community structure. In particular, the results reveal that the clustering of similar agents has a bifurcating function for the opinion dynamics. Given that the inter-communal influence is high, the clustering fosters the global consensus. If the inter-communal influence is weak, the clustering would instead intensify polarization and thus hinder the formation of global consensus. The factors of the communal tolerances and interconnectivity leverage the bifurcating effect.