DevOps-Blog
What Is DevOps?
In today's fast-moving tech world, speed, collaboration, and automation are the keys to building and running successful software systems. Companies like Netflix, Amazon, and Google release new features thousands of times a day — safely and reliably.
But how?
The answer is DevOps.
What is DevOps?
DevOps is a cultural and technical movement that brings together Development (Dev) and Operations (Ops) teams to work more collaboratively and deliver software faster, better, and more reliably.
In simple terms:
DevOps is a set of practices and tools that combines software development and IT operations to shorten the development life cycle and deliver high-quality software continuously.
It’s not just about tools — it’s about people, process, and technology working together.
Why Does DevOps Matter?
Traditional development teams work in silos:
- Developers write code.
- Operations deploy and manage that code.
- Communication is slow.
- Releases are infrequent and risky.
With DevOps:
- Everyone collaborates from the start.
- Automation replaces manual steps.
- Software is tested, integrated, and deployed continuously.
- Problems are identified and fixed faster.
Result: Faster releases, fewer bugs, happier users, and more resilient systems.
Bash Scripting: Automating User Management
Efficiency, automation, and security are key in DevOps. Scripting allows you to perform complex tasks reliably and automatically. Below, we explore a Bash script that automates Linux user creation and explain why understanding such scripts is essential for aspiring DevOps engineers.
What the Script Does
- Creates a user with a home directory on Linux servers
- Generates a secure temporary password
- Forces password change on first login
- Sets password expiry to 90 days
- Adds user to
sudo(Ubuntu) orwheel(Red Hat) - Sets up SSH key authentication from provided public key
- Configures home directory permissions to restrict access
Full Script
#!/bin/bash
# Prompt for username
read -p "Enter username to create: " USERNAME
# Prompt for SSH public key
echo "Paste the user's SSH public key below, then press Enter and Ctrl+D when done:"
PUBKEY=$(cat)
# Validate input
if [ -z "$USERNAME" ]; then
echo "Username cannot be empty."
exit 1
fi
if [ -z "$PUBKEY" ]; then
echo "Public key cannot be empty."
exit 1
fi
# Generate secure password
TEMP_PASS=$(openssl rand -base64 12)
# Detect Linux distribution
if grep -qi ubuntu /etc/os-release; then
DISTRO="ubuntu"
elif grep -qi 'red hat\\|centos\\|fedora' /etc/os-release; then
DISTRO="redhat"
else
echo "Unsupported Linux distribution"
exit 1
fi
echo "Creating user $USERNAME on $DISTRO"
# Create user
if id "$USERNAME" &>/dev/null; then
echo "User $USERNAME already exists!"
else
if [ "$DISTRO" == "ubuntu" ]; then
sudo adduser --disabled-password --gecos "" "$USERNAME"
else
sudo adduser "$USERNAME"
fi
fi
# Set temporary password
echo "$USERNAME:$TEMP_PASS" | sudo chpasswd
# Force password change
sudo chage -d 0 "$USERNAME"
# Set password expiry
sudo chage -M 90 "$USERNAME"
# Add user to group
if [ "$DISTRO" == "ubuntu" ]; then
sudo usermod -aG sudo "$USERNAME"
else
sudo usermod -aG wheel "$USERNAME"
fi
# Configure SSH key authentication
sudo mkdir -p /home/$USERNAME/.ssh
echo "$PUBKEY" | sudo tee /home/$USERNAME/.ssh/authorized_keys > /dev/null
sudo chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
sudo chmod 700 /home/$USERNAME/.ssh
sudo chmod 600 /home/$USERNAME/.ssh/authorized_keys
# Print completion
echo "User $USERNAME created successfully."
echo "Temporary password: $TEMP_PASS"
Why This Matters in DevOps
- Automation: Reduce repetitive tasks and errors.
- Security: Enforce consistent policies and SSH key usage.
- Efficiency: Ensure uniform configuration across servers.
- Learning: Understand Linux internals and best practices.
Take the Next Step: Learn DevOps
Mastering scripting is just the beginning. Our DevOps Bootcamp teaches automation, cloud infrastructure, CI/CD, Docker, Kubernetes, and more.
Ansible: The Secret Weapon of DevOps Automation
Speed, consistency, and reliability are everything in DevOps. Tools like Ansible automate complex tasks across thousands of servers with just a few lines of code.
What Is Ansible?
- Configuration management
- Application deployment
- Task automation
- Infrastructure as code (IaC)
It uses YAML files and SSH connections — no agents required.
Key Features
- Agentless
- Simple syntax (YAML)
- Idempotent
- Extensible
- Scalable
- Secure (SSH-based)
Example Playbook
---
- name: Create a config file on 200 servers
hosts: all
become: yes
tasks:
- name: Create a file
copy:
dest: /etc/myconfig.conf
content: "This is my configuration file for all servers."
Run it with:
ansible-playbook -i inventory.ini create_config.yml
Infrastructure as Code (IaC): Build, Deploy & Scale the Smart Way
Infrastructure as Code (IaC) is the practice of managing and provisioning infrastructure using code rather than manual processes. Tools like Terraform and CloudFormation allow teams to automate cloud environments efficiently.
Why IaC Matters
- Consistency: Infrastructure can be replicated easily.
- Speed: Deploy entire environments in minutes.
- Version Control: Track changes just like software code.
- Collaboration: Developers and Ops share the same source of truth.
Terraform Example
# Create an AWS EC2 instance
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "web" {
ami = "ami-12345678"
instance_type = "t2.micro"
tags = {
Name = "WebServer"
}
}
Deploy it with:
terraform init
terraform apply -auto-approve
Why Learn IaC?
- Automate infrastructure provisioning
- Eliminate configuration drift
- Integrate seamlessly with CI/CD pipelines
- Be job-ready for modern DevOps roles
Start Automating Your Cloud Career
From Bash to Ansible to Terraform — automation is the heart of DevOps. Learn to deploy and scale systems like a pro.