How to Use Bash & Python for Real DevOps Automation – Full Handbook with 5 Production Use Cases

Iniciado por joomlamz, 28 de Maio de 2026, 01:50

Respostas: 0   |   Visualizações: 8

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.


                     How to Use Bash & Python for Real DevOps Automation – Full Handbook with 5 Production Use Cases
               




Tópico:
                     How to Use Bash & Python for Real DevOps Automation – Full Handbook with 5 Production Use Cases
               
Categoria: Tutoriais | FreeCodeCamp Premium
Idioma Principal: Português (Conteúdo de Tecnologia)

Conteúdo do Tutorial / Guia Passo a Passo:
-------------------------------------------------------------------------
Automation scripts often validate process completion instead of system health.

A Kubernetes pod can be running while the application inside it can't authenticate to the database. A Terraform deployment can return clean while someone has manually changed infrastructure in the cloud console. A canary rollout can show zero errors while users wait five seconds for every request.

The problem isn't the tooling. The problem is that the system can look healthy when it really is not.

This handbook walks through five production-style automation scenarios using Bash and Python for:

• Detecting abnormal AWS spend before the monthly invoice arrives

• Correlating logs across multiple services using trace IDs

• Finding infrastructure drift outside Terraform

• Validating secret rotation at the application level

• Automatically rolling back slow deployments before users complain

By the end of this handbook, you'll be able to build small scripts that help you notice when something is wrong in a system, even when the tools say everything is fine.

The scripts are intentionally small. The important part is the operational thinking behind them like what signal the script measures, what failure mode it can detect, and what assumptions the platform is making underneath.

Each use case includes a runnable demo environment, the complete script, a breakdown of the system behaviour involved, and an intentional failure you can trigger yourself.

If you're new to this workflow, start with use case 1 and work forward. The later sections build on the same pattern: automation is useful when it verifies reality, not just process completion.

Prerequisites

Before you start, set up the following:

• Python 3.8 or higher – check with
python3 --version
• A Python virtual environment – create one before installing anything:

python3 -m venv venv
source venv/bin/activate

# on Windows:

venv\Scripts\activate

This keeps your installed packages isolated from your system Python and prevents permission errors on shared machines.

• pip – Python's package installer, included with Python

• AWS CLI configured with a working profile – a free-tier AWS account is enough for use cases 1, 3, and 4. Verify it's working with:

aws sts get-caller-identity

• Docker and Docker Compose – needed for use cases 2, 4, and 5

• Kind (Kubernetes in Docker) – a way to run Kubernetes locally for use cases 4 and 5. Install with
brew install kindon macOS, or follow the Kind quick start guide

• kubectl – the command-line tool for talking to a Kubernetes cluster. After installing Kind, run
kind create clusterand kubectl is configured automatically

• Helm – a package manager for Kubernetes, needed for use case 5. Install with
brew install helmor the Helm install guide

• Terraform – needed for use case 3. Install with
brew install terraformon macOS or follow the Terraform install guide. Check with
terraform version.

• bc – a calculator utility used by the canary watch scripts for floating-point comparison. Install with
brew install bcon macOS or
apt install bcon Ubuntu. Run
bc --versionto confirm it is available before starting use case 5.

Knowledge and Skills

• You should be comfortable reading Python and Bash scripts without needing to write them from scratch.

• You should have basic Linux terminal com

... [O tutorial continua no link abaixo] ...


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: