Industry 4.0 provides a framework for integration of cyber-physical systems (CPS), internet of things (IoT), internet of services (IoS) and internet of data (IoD) with the manufacturing domain so as to make it smart, flexible and adaptable to the dynamic market changes and the customer requirements. It will enable companies to form a connected "smart manufacturing" ecosystem having interconnections between the suppliers, manufacturers, distributors and even the products in order to provide better services to the end customer. However, due to the presence of heterogeneous systems that might not adhere to the industrial standards, there is a gap in achieving this vision of an interconnected ecosystem. In this paper, we focus on providing a solution for the modularity and interoperability issues related to the Industry 4.0 from a systems integration viewpoint. We propose a model-based approach for modular complex systems development by separating (1) the behavior model and (2) the implementation logic (execution) of the system. Moreover, we use unified modeling language (UML) based modeling techniques to model system behavior and connect the behavior models to the application programming interface (API) of the CPS. Thus, instead of generating source code for the CPS using models, we directly execute the CPS in the physical world via model execution. The model execution is supported by the standard execution semantics of UML. Using our approach, multiple heterogeneous systems can be modeled and integrated together to create a "plug and play" ecosystem needed for achieving the vision of Industry 4.0.