Automation in IT

Automating your IT infrastructure whether it is for your job or your home lab is a great way to ensure that your environment can be spun up quickly and replicated at a moment's notice.

Automation in IT

Happy New Year! 🎉🎉🎉

People all over the world celebrated the beginning of 2025 this week and made their promises and resolutions of self-improvement and positive changes. I thought that I would share some tools that would allow developers all over the world to have more time to focus on their goals and larger projects rather than tedious and menial tasks. Automating IT infrastructure is a great way to save time on server building, configuration, cloud resource provisioning, and more. Using IaC to save time, reduce errors, and speed up deployments is a great way to make time for the gym and other good habits we probably won't continue past this week!


Glossary

Automation

Automation is reducing the amount of human involvement to complete actions by using technology. Automation excels at replacing man power with technology in repetitive tasks in almost all industries. However, it is prevalent mostly in the industries of manufacturing, robotics, as well as in IT systems. In this post we will focus on automation's role in IT systems and how it can help streamline development and the creation of virtual infrastructure.

IaC (Infrastructure as Code)

Infrastructure as code (IaC) is the ability to create and maintain your virtual infrastructure using human-readable code instead of manually configuring processes and settings. Applications require components like operating systems, database connections, and storage. With this comes a developer or team of developers who have to frequently configure, update, and maintain the infrastructure to develop, test, and deploy applications.

To avoid tedious, time-consuming, and error prone labor when managing applications (especially at scale), IaC allows the developer to define the state of the infrastructure they need as well as the steps needed to be taken to reach that desired state.

The benefits are simple:

  • easy to duplicate infrastructures
  • reduces configuration errors
  • source control and versioning

In this post, we are going to be exploring some of the most popular industry standard IaC tools and what differences exist between them.


Terraform

Hashicorp Terraform is an IaC tool that allows for the scripting of cloud and on premise resources in readable configuration files that can be reused, versioned, and shared. Terraform can manage low to high-level components from compute, storage, and networking to DNS and SaaS (Software as a Service) features. To code with Terraform, you must use

Terraform manages resource configuration and creation on services through the APIs (Application Programming Interfaces) offered by the services. All API providers that are compatible with Terraform can be found on the Terraform Registry. Included in the registry are popular providers such as AWS, Azure, GCP, Kubernetes, Helm, GitHub, Splunk, DataDog, and more.

Terraform's workflow consists of three stages:

  • Write: Defining the resources which can be across multiple cloud providers and services.
  • Plan: Terraform creates an execution plan describing the infrastructure it will create, update, or destroy based on the existing infrastructure and your configuration.
  • Apply: On approval, Terraform performs the proposed actions in the proper order while respecting any dependencies needed to be added.

What are Terraform modules?

A Terraform module is a collection of configuration files in a directory. They group resources together that are dedicated to one task, this allows for code and logic to be reused when developing similar components.

Any resource in the .tf files of a Terraform configuration are root modules. Which means all configurations possess a root module. Every module can call other module, those modules that are called within other modules are called child modules. This is done by using the module block in a Terraform configuration:

module "webservers" {
   source = "../webservers"
}

A local module is one that is not in any registry and when sourced it is using the direct path to that module. A published module is the opposite, it is a module that has been pushed to a Terraform Registry or a VCS tag has been associated to it, when sourced the URL of that module is used to locate it.


Ansible

Ansible is a an IaC tool that is popular for its ease of use. Ansible Automation Platform is open source, command-line IT automation software application that uses YAML-based "playbooks" to configure systems, deploy software, and support application updates, networking, and operation. Unlike other IaC tools such as Chef, Ansible does not require the installation of an agent on managed nodes which simplifies and speeds up the setup and deployment process. Like Terraform, it has plenty of support for cloud-based service providers.

Ansible works of the control node and managed node concept. The control node is where the instructions are executed, it then distributes the modules to the managed nodes which are the machines being automated. In order to communicate with managed nodes, Ansible uses SSH.

What are Playbooks and Modules?

An Ansible playbook is a collection of tasks that define the actions to be performed on the managed nodes, while a module is the instruction of a single task. A playbook is essentially a structured formatting of a series of multiple modules.

Here is what an example apache.yml playbook may look like:

---
- name: Apache server installed
  hosts: web
  become: true
  tasks:

    - name: Install Apache
      ansible.builtin.dnf:
        name: httpd

    - name: Apache enabled and running
      ansible.builtin.service:
        name: httpd
        enabled: true
        state: started

    - name: Copy index.html
      ansible.builtin.copy:
        src: web.html
        dest: /var/www/html/index.html
        mode: '644'

Chef

Chef is an IaC tool written in Ruby DSL (domain specific language). Similar to Ansible's playbooks and Terraform's modules, Chef uses cookbooks and recipes (yes, they fully intended the pun) to automate configuration, deployment, management whether on-premise or in the cloud of infrastructure. The Chef tool has a heavy emphasis on the verification and testing of configurations to ensure any issues are identified and addressed before reaching a production environment.

Chef operates on an agent-based architecture. The Chef client must run on each managed node to communicate with the central Chef server to receive an execute configuration instructions.

The verification mentioned earlier is found through the Chef Workstation. This is used to make sure the cookbook you have created does exactly what you intend before shipping it out to your servers. Chef Workstation consists of Cookstyle, ChefSpec, Chef InSpec, and Test Kitchen testing tools. Cookstyle ensures that the syntax of the cookbook is correct and meets the standard of Chef. Test Kitchens are small virtual environments accessed from the console to test and check that the environment builds out all the tools and services you specified in the cookbook.


Which should I use?

Terraform, Ansible, and Chef are three of a variety of different tools used to automate IT infrastructure. Just like Podman and Docker in containerization, the choice of which tool is the best fully depends on your goals and current configurations with your IT infrastructure. Choosing the proper tool that matches the coding skillset of your team, amount of time available to complete the project, security requirements of your project, and level of interoperability with other APIs makes the winning choice unique for every team.

Sources

  • https://www.redhat.com/en/topics/automation/understanding-ansible-vs-terraform-puppet-chef-and-salt
  • https://www.redhat.com/en/topics/automation
  • https://aws.amazon.com/what-is/iac/
  • https://developer.hashicorp.com/terraform/intro
  • https://spacelift.io/blog/what-are-terraform-modules-and-how-do-they-work
  • https://www.redhat.com/en/ansible-collaborative/how-ansible-works#:~:text=Ansible%20is%20an%20open%20source,simplicity%20and%20ease%20of%20use.
  • https://docs.chef.io/platform_overview/