The availability of many Infrastructure as Code (IaC) languages and tools in the IT automation and infrastructure provisioning world makes it difficult to know and use all of them. A possible solution to this problem, designed and implemented in the PIACERE project, is an Infrastructure Code Generator (ICG) which transforms an abstract model into infrastructural code from different IaC languages.
The target activities of the PIACERE framework are: provisioning, configuration, deployment and orchestration for the IT infrastructure domain. At the time of writing, both provisioning and configuration functionalities are implemented, through the collaboration of several PIACERE components.
The IGC component has been developed to generate executable infrastructural code (IaC) starting from models written in the DevSecOps Modelling Language (DOML). Like a compiler, the ICG receives and parses a DOML file in input and generates IaC code for Terraform and/or Ansible as output. Other components related to ICG, like IaC Execution Manager (IEM) and Integrated Development Environment (IDE) are part of the PIACERE framework. The main functionality and the integration between ICG and these components will be described later in this article.
For a more detailed description of the main ICG functionalities, see the following two articles previously published in the PIACERE blog: Automatic generation of Ansible and Terraform code , and Infrastructure Code Generator: now complete and highly extensible .
With the latest ICG version, the parser functionality, the extensibility and the integration have been enhanced to implement the approach that is now known as Low-Code/No-Code (LCNC or NCLC). Low-Code and No-Code are methods to design and develop applications using intuitive graphical tools like the PIACERE IDE. Although the Low-Code and No-Code frameworks are built on actual coding languages like PHP, Java and Python libraries, end users are not concerned with low level coding details. This makes possible for a non-technical business user to develop applications without having to write even a single line of code.
The main benefits using this approach to produce IaC code are that there is no need to learn languages like Terraform or Ansible, DevOps costs are lowered and delivery times are shortened. Repeatability and extendibility of the model complete the list of the advantages.
To describe how ICG applies the LCNC concept, a description of the ICG Process Flow and its graphical representation are provided below.
(1) As a first step, a model is produced in the high level declarative language DOML to describe the desired infrastructure. (2) The ICG Parser navigates the DOML model, using the PyEcore Python library, to identify, reorganize and extract the information needed. (3) The same ICG Parser then creates an Intermediate Representation: it is a JSON file that contains all the parameters for each object to be generated, including the target IaC languages and the target service provider. (4) Finally, the language-specific plugins generate the resulting target IaC code.
The ICG extension mechanism is based on new templates to support new primitives and new target platforms like AWS, GCP and Azure. The current ICG version produces Terraform code for deployment/provisioning and Ansible code for configuration activities. In future releases it may be possible to select other IaC languages.
The next diagram shows the workflow of the ICG integration with other related PIACERE components (DOML, IDE and IEM).
The graphical user interface (IDE GUI) is used by the user to create DOML models, and the ICG (running in a docker container) is integrated with the IDE through a REST API.
(1) The IDE calls the ICG component passing the new created DOML, and the ICG returns a compressed archive containing the IaC files and the related execution instructions to be used by the IEM component.
(2) The files produced by the ICG are structured in a specific hierarchy and coded for reading by the other components of the PIACERE framework.
The following picture shows the IDE GUI used to invoke the ICG .
(3) In the PIACERE workflow, the IEM is the Execution Manager component. It is configured to execute the IaC files provided in the compressed archive generated by the ICG and shown in the picture below
In addition to the IaC sources implementing the model, other IaC files are created by the ICG to provision specific PIACERE runtime components, such as the monitoring agents dedicated to the target application and other agents that extend the framework capabilities like the security agents.
The ICG source code has been released in open source and pushed in a public gitlab repository . A video demo is also available showing the results mentioned in this article .
- HPE, Automatic generation of Ansible and Terraform code. PIACERE Blog, 17 December 2020, online at: https://www.piacere-project.eu/blog/title-automatic-generation-ansible-and-terraform-code
- HPE, Infrastructure Code Generator: now complete and highly extensible. PIACERE Blog, 13 April 2021. Online at: https://www.piacere-project.eu/blog/infrastructure-code-generator-now-complete-and-highly-extensible
- ICG source code, online at: https://git.code.tecnalia.com/piacere/public/the-platform/icg
- ICG video demo, online at: https://www.youtube.com/watch?v=AtVzqzmLN18