DevOps and
Infrastructure
as Code
Introduction
• DevOps is a methodology in the
software development and IT
industry. Used as a set of practices
and tools, DevOps integrates and
automates the work of software
development.
DevOps
Tools
DevOps Tools
• Git
• GitHub
• Jenkins
• Docker
• Maven
• Jira
• Slack
• Kubernetes
• Continuous integration (CI)
• Continuous delivery (CD)
• Continuous deployment
Getting started with DevOps
The term DevOps was introduced in 2007-2009 by Patrick
Debois, Gene Kim, and John Willis, and it represents
the combination of Development (Dev) and Operations
(Ops).
DevOps culture is a set of practices that reduce the
barriers between developers and operations.
DevOps culture is also the extension of agile
processes.
The DevOps
movement is based on
three axes:
The culture of collaboration: people are brought together by making
multidisciplinary teams that have the same objective.
Processes: teams must follow development processes from agile
methodologies with iterative phases that allow for better functionality,
quality, and rapid feedback.
The DevOps process is divided into several phases:
A. Planning and prioritizing functionalities
B. Development
C. Continuous integration and delivery
D. Continuous deployment
E. Continuous monitoring
Tools: The choice of tools and products used by teams is very important in
DevOps.
• The benefits of establishing a DevOps culture within an
enterprise are as follows:
• Better collaboration and communication in teams, which has a
human and social impact within the company
• Shorter lead times to production, resulting in better performance and
end user satisfaction
• Reduced infrastructure costs with IaC
• Significant time saved with iterative cycles that reduce application
errors and automation tools that reduce manual tasks, so teams focus
more on developing new functionalities with added business value.
Implementing CI/CD and continuous
deployment
There are three practices:
• Continuous integration (CI)
• Continuous delivery (CD)
• Continuous deployment
"Continuous integration is a software
development practice where members
of a team integrate their work frequently... Each
integration is verified by
Continuous an automated build (including test) to detect
integration errors as quickly
integration as possible.“
(CI)
CI is an automatic process that allows you to
check the completeness of an application's code
every time a team member makes a change. This
verification must be done as quickly as possible.
Therefore, to set up CI, it is necessary to have
a Source Code Manager (SCM) that will
centralize the code of all members. This code
manager can be of any type: Git, SVN, or
Team Foundation Version Control (TFVC).
Implementing It's also important to have an automatic build
CI manager (CI server) that supports continuous
integration, such as Jenkins, GitLab CI,
TeamCity, Azure Pipelines, GitHub Actions,
Travis CI, and Circle CI.
The continuous integration workflow
Continuous delivery (CD)
Once continuous integration has been completed, the next step is
to deploy the
application automatically in one or more non-production
environments, which is called staging. This process is called
continuous delivery (CD).
The continuous delivery workflow
Continuous deployment is an extension of CD,
Continuous but this time, with a process that automates the
entire CI/CD pipeline from the moment the
deployment developer commits their code to deployment in
production through all the verification steps.
The continuous deployment workflow
Understanding IaC practices
• IaC is a practice that consists of writing the code of the resources that make up
an infrastructure.
• IaC is the process of writing the code of the provisioning and configuration
steps of infrastructure components, which helps automate its deployment in a
repeatable and consistent manner.
The benefits of IaC
The benefits of IaC are as follows:
• The standardization of infrastructure configuration reduces the risk of errors.
• The code that describes the infrastructure is versioned and controlled in a
source code manager.
• The code is integrated into CI/CD pipelines.
• Deployments that make infrastructure changes are faster and more efficient.
• There's better management, control, and a reduction in infrastructure costs.
IaC languages and tools
The languages and tools that are used to write the configuration of the
infrastructure can be of different types; that is, scripting, declarative, and
programmatic.
Scripting types
• These are scripts such as Bash, PowerShell, or others that use the different
clients (SDKs) provided by the cloud provider; for example, you can script the
provisioning of an Azure infrastructure with the Azure CLI or Azure
PowerShell.
• Using the Azure CLI-command line Interface (the documentation is available
at [Link] we have the following:
az group create -location westeurope -name MyAppResourcegroup
Azure Resource group-MyAppResourcegroup
Why Resource Groups are important
• Organize related resources, Manage access control,
Apply policies, Delete all resources together when no
longer needed
Using Azure PowerShell (the documentation is available at [Link] ly/2VcASeh), we have the
following:
New-AzResourceGroup -Name MyAppResourcegroup –Location westeurope
These are languages in which it is sufficient to write the
Declarative state of the desired system or infrastructure in the form of
configuration and properties.
types
•The first task installs Nginx using the apt module with the state=latest option,
ensuring it's the latest version available in the repository.
•The second task starts the Nginx service using the service module with state: started.
This ensures that Nginx is running on the server after installation.
Example
more union between developers and operations so that we
see the
Programmati emergence of IaC tools that are based more on languages
known by developers, such as
c types TypeScript, Java, Python, and C#.
Optimizing Infrastructure
Deployment with Packer
• The cloud providers have integrated a service
that allows them to create or generate custom
VM images.
The benefits of using these images are as
follows:
• The provisioning of a VM from an image is very
fast.
• Each VM is uniform in configuration and, above
all, is safety compliant.
• Infrastructure as Code (IaC) tools- Packer from
Packer is part of the HashiCorp open source
suite of tools, and this is the official Packer
An page: [Link]
overview It's an open source command-line tool that
allows us to create custom VM images of any
of Packer OS (these images are also called templates) on
several platforms from a JSON file.
Packer, like Terraform, is a cross-platform tool
and can be installed on Windows, Linux, or
Installing macOS. The installation of Packer is almost
Packer identical to the Terraform installation and can
be done in two ways: either manually or via a
script.
To install Packer manually, use the following
steps:
1. Go to the official download page
([Link] html) and
Installing download the package corresponding to your
manually operating system.
2. After downloading, unzip and copy the
binary into an execution directory (for
example, inside c:\Packer).
3. Then, the PATH environment variable must
be set with the path to the binary directory.
It is also possible to install Packer with an automatic
script that can be installed on a remote server and be
used on a CI/CD process.
Installing Packer by script on Windows
Installing by • On Windows, we can use Chocolatey, which is a
software package manager. Chocolatey is a free
script public package manager, like NuGet or npm, but
dedicated to software.
• It is widely used for the automation of software on
Windows servers or even local machines.
• Chocolatey's official website is here:
[Link] and its installation
documentation is here: [Link]
Once Chocolatey is installed, we just need to
run the following command in PowerShell or in
the CMD tool:
choco install packer -y
Install The following is a screenshot of the Packer
installation for Windows with Chocolatey:
Packer
The execution of choco install packer -y
installs the latest version of Packer
from Chocolatey.
Checking the Packer
installation
• Once installed, we can check
the installed version of Packer
by running the following
• command:
• packer --version
• This command displays the
installed Packer version: