Overview
Infrastructure as Code (IaC) is the managing and provisioning of infrastructure through code instead of through manual processes.
With IaC, configuration files are created that contain your infrastructure specifications, which makes it easier to edit and distribute configurations. It also ensures that you provision the same environment every time. By codifying and documenting your configuration specifications, IaC aids configuration management and helps you to avoid undocumented, ad-hoc configuration changes.
Version control is an important part of IaC, and your configuration files should be under source control just like any other software source code file. Deploying your infrastructure as code also means that you can divide your infrastructure into modular components that can then be combined in different ways through automation.
Automating infrastructure provisioning with IaC means that developers don’t need to manually provision and manage servers, operating systems, storage, and other infrastructure components each time they develop or deploy an application. Codifying your infrastructure gives you a template to follow for provisioning, and although this can still be accomplished manually, an automation tool, such as Red Hat® Ansible® Automation Platform, can do it for you.
Declarative vs. imperative approaches to IaC
There are 2 ways to approach IaC: declarative or imperative.
A declarative approach defines the desired state of the system, including what resources you need and any properties they should have, and an IaC tool will configure it for you.
A declarative approach also keeps a list of the current state of your system objects, which makes taking down the infrastructure simpler to manage.
An imperative approach instead defines the specific commands needed to achieve the desired configuration, and those commands then need to be executed in the correct order.
Many IaC tools use a declarative approach and will automatically provision the desired infrastructure. If you make changes to the desired state, a declarative IaC tool will apply those changes for you. An imperative tool will require you to figure out how those changes should be applied.
IaC tools are often able to operate in both approaches, but tend to prefer one approach over the other.
Red Hat Resources
Benefits of IaC
Provisioning infrastructure has historically been a time-consuming and costly manual process. As virtualization, containers, and cloud computing have become the norm, infrastructure management has moved away from physical hardware in data centers—providing many benefits, but also creating some new challenges.
With cloud computing, the number of infrastructure components has grown, more applications are being released to production on a daily basis, and infrastructure needs to be able to be spun up, scaled, and taken down frequently. Without an IaC practice in place, it becomes increasingly difficult to manage the scale of today’s infrastructure.
IaC can help your organization manage IT infrastructure needs while also improving consistency and reducing errors and manual configuration.
Benefits:
- Cost reduction
- Increase in speed of deployments
- Reduce errors
- Improve infrastructure consistency
- Eliminate configuration drift
Extending IaC strategy into Day 2 operations
Building on the strategic foundation of IaC, organizations are beginning to use these practices to automate IT processes at every stage of the operational life cycle.
Just as IaC standardizes the build, provisioning, and deployment of infrastructure, IT teams can adopt Ops as Code (OaC) to codify the management and maintenance of systems after they are deployed. This approach can then be extended into Policy as Code (PaC) to automate governance, risk, and compliance processes for applications and solutions.
Using the experience gained from automating IaC, IT teams can use the same methods and tools to take a more efficient, adaptable approach to Day 2 operations.
IaC tools
Server automation and configuration management tools can often be used to achieve IaC. There are also solutions specifically for IaC.
These are some popular choices:
- Chef
- Puppet
- Red Hat® Ansible® Automation Platform
- Saltstack
- Terraform
- AWS CloudFormation
Using an automation tool to implement IaC can also help to build more efficient, productive workflows and streamline the adoption of a NetOps methodology. Comprehensive platforms, like Ansible Automation Platform, can be used to provision operating systems and network devices, deploy applications, and manage configuration across enterprise environments.
Why does IaC matter for DevOps?
IaC is an important part of implementing DevOps practices and continuous integration/continuous delivery (CI/CD). IaC takes away the majority of provisioning work from developers, who can execute a script to have their infrastructure ready to go. That way, application deployments aren’t held up waiting for the infrastructure, and sysadmins aren’t managing time-consuming manual processes.
CI/CD relies on ongoing automation and continuous monitoring throughout the application life cycle, from integration and testing to delivery and deployment. In order for an environment to be automated, it needs to be consistent. Automating application deployments doesn’t work when the development team deploys applications or configures environments one way and the operations teams deploys and configures another way.
Aligning development and operations teams through a DevOps approach leads to fewer errors, manual deployments, and inconsistencies. IaC helps you to align development and operations because both teams can use the same description of the application deployment, supporting a DevOps approach.
The same deployment process should be used for every environment, including your production environment. IaC generates the same environment every time it is used. IaC also removes the need to maintain individual deployment environments with unique configurations that can’t be reproduced automatically and ensures that the production environment will be consistent.
DevOps best practices are also applied to infrastructure in IaC. Infrastructure can go through the same CI/CD pipeline as an application does during software development, applying the same testing and version control to the infrastructure code.
Why choose Red Hat for automation?
Creating an enterprise-wide approach to automation lets you automate not only IT processes, but also entire technologies, teams, and organizations.
Red Hat Ansible Automation Platform includes all the tools needed to implement enterprise-wide automation, including playbooks, a visual dashboard, an event-driven solution, and analytics. It also uses webhooks to automate IaC workflows and enable GitOps practices.
Ansible Playbooks, written in YAML, describe the desired state of your systems, which are usually kept in source control. Ansible Automation Platform does the work of getting your systems to the desired state, no matter their current state.
Ansible Automation Platform makes your installations, upgrades and day-to-day management repeatable and reliable.
With an Ansible Automation Platform subscription, you can deploy new applications and services faster, manage IT infrastructure more efficiently, and see an increase in app development productivity. And you’ll get access to certified content from our robust partner ecosystem, hosted management services, and life cycle technical support so your teams can create, manage, and scale automation across your organization.
The built-in capabilities of Red Hat Ansible Automation Platform provide an accelerator in a box. It’s the de facto standard that many of our vendors and partners also use to write scripts to install, configure, and maintain their technology.
The official Red Hat blog
Get the latest information about our ecosystem of customers, partners, and communities.