π Why do you need to choose a programming language?
In DevOps, you will need to use programming languages to:
- β
Write automation scripts.
- β
Manage servers and cloud.
- β
Create tools to support CI/CD.
- β
Build and deploy Infrastructure as Code (IaC).
Choosing the right language helps you work more efficiently with systems, automate many processes, and improve software development speed.
π₯ Suitable languages for DevOps
π Python (Main recommendation)
πΉ Reasons to choose Python:
- Easy-to-read syntax, easy to learn.
- Rich libraries supporting automation like
fabric, paramiko, boto3 (AWS SDK), pyinfra. - Strong support in Cloud management (AWS, GCP, Azure).
πΉ Practical applications:
- Write automated code deployment scripts.
- Create server management bots.
- Build system management APIs.
π Example: Automated SSH deployment script with Paramiko
1
2
3
4
5
6
7
8
9
10
11
| import paramiko
def deploy_code(host, user, password, command):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=host, username=user, password=password)
stdin, stdout, stderr = client.exec_command(command)
print(stdout.read().decode())
client.close()
deploy_code('192.168.1.100', 'ubuntu', 'yourpassword', 'git pull origin main && systemctl restart app')
|
π₯οΈ Bash (Need to know basics)
πΉ Reasons to choose Bash:
- The most popular shell script on Linux.
- Helps you work quickly with the system.
- Optimized for server management and small task automation.
πΉ Practical applications:
- Write automated server update scripts.
- Create periodic cron jobs.
- Manage users and permissions on Linux.
π Example: Automated server update script
1
2
| #!/bin/bash
sudo apt update && sudo apt upgrade -y
|
π Go (Golang) (If working with Kubernetes)
πΉ Reasons to choose Go:
- High performance, easy to compile into compact binaries.
- Kubernetes and many DevOps tools like Terraform are written in Go.
πΉ Practical applications:
- Write container management tools.
- Create plugins for Kubernetes.
- Build custom DevOps tools.
1
2
3
4
5
6
7
8
9
10
| package main
import (
"fmt"
"os"
)
func main() {
hostname, _ := os.Hostname()
fmt.Println("Hostname:", hostname)
}
|
βοΈ Groovy (If working with Jenkins)
πΉ Reasons to choose Groovy:
- The main language for writing pipelines in Jenkins.
- Flexible syntax, easy to extend and integrate with Java.
πΉ Practical applications:
- Write CI/CD pipelines for Jenkins.
- Create system management scripts.
- Automate build, test, deploy steps.
π Example: Basic pipeline in Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building the project...'
sh 'mvn clean package'
}
}
stage('Test') {
steps {
echo 'Running tests...'
sh 'mvn test'
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
sh './deploy.sh'
}
}
}
}
|
π― Conclusion
- β
Python + Bash is the best choice to start with DevOps.
- β
If working with Kubernetes, learn Go as well.
- β
If working with Jenkins, learn Groovy to write pipelines.
π Next step: Learn the basics of Linux & operating systems.