In distributed systems like those based on cloud or service-oriented frameworks, applications are typically assembled by deploying and connecting a large number of heterogeneous software components, spanning from fine-grained packages to coarse-grained complex services. Automation techniques and tools have been proposed to ease the deployment process of these complex system. By relying on a formal model of components, we describe a sound and complete algorithm for computing the sequence of actions that permits the deployment of a desired configuration even in the presence of circular dependencies among components. We give a proof for the polynomiality of the devised algorithm and exploit it to develop METIS, a tool for computing deployment plans. The validation of METIS has been performed in two ways: on the one hand, by considering artificial scenarios consisting of a huge number of different components synthesized by following typical configuration patterns and, on the other hand, by exploiting it to deploy real-life installations of a WordPress blogging service.