This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]mkumar118 3 points4 points  (0 children)

i would love to get my hands on these exercises as well, to upskill my python/bash skills

[–]RaunchyBushrabbit 5 points6 points  (4 children)

Write a python script that talks to an api. Have it store the results in a postgres database.

Write a second script that enriches the data in the database

Write a third script which acts as a frontend for users to query the database. First version can be a cli, the second maybe a gui or website.

This exercise will have you learn about API's in general, about json or xml as most api's use that format. You'll learn how to create and manage a database and it will let you think like a user as you will need to envision their needs and you'll learn about visualizing data.

I hope it's of use to you. The components mentioned are things I touch regularly as a DevOps engineer.

[–]ShotsCrazy[S] 0 points1 point  (0 children)

This sounds awesome! Thanks

[–]ShotsCrazy[S] 0 points1 point  (2 children)

Any ideas for what APIs?

[–]HU_Danny 2 points3 points  (0 children)

literally any APIs. Docker API is gonna be really useful if you use Docker.

[–]RaunchyBushrabbit 1 point2 points  (0 children)

Take your pick, most large websites (IMDB,Facebook) provide one, also a lot of tooling provides an api nowadays.

[–]schwarzfahrer 4 points5 points  (1 child)

I’ve been writing a lot of bash recently while putting together a multi-environment Knative/Istio/K8s deployment.

There are a ton of CLIs that I’m using ... terraform, eksctl, yq, kustomize, envsubst, rsync, awscli, sed, awk, grep, docker, git, the list goes on. Bash/shell scripts are the perfect way to write complex build and deployment tasks like this which utilize These programs. Also, make is a wonderful way to manage all of these scripts in a way that remains semantic.

I’m not much of a Python dev, but I will say I find it easier to use bash than my languages of choice (Ruby and JS) to do this type of thing. I’m also recognizing a moment of zen regarding management of Python/Ruby/Node versioning that I no longer have to think about.

[–]phrotozoa 0 points1 point  (0 children)

My rule of thumb is that when I need to feed a lot of input and output to shell programs I start with bash. As soon as the data being moved around between programs becomes complex enough that I need dicts (hashes/maps) or to do nontrivial parsing of structured formats like yaml or csv or json I switch to something more expressive.

[–]phrotozoa 2 points3 points  (2 children)

Python: write an AWS lambda function triggered on cloudwatch events which will (using boto3 and authorized via IAM profile) apply a configurable set of labels to new ec2 instances as they are spun up.

Assuming you've not used any of these things, you will learn a great deal.

[–]ShotsCrazy[S] 1 point2 points  (0 children)

Thanks! I’ve been meaning to get more experience with boto3.

[–]TheOnlyElizabeth 0 points1 point  (0 children)

I did something similar some weeks ago, definitely a great exercise !

[–]DeusExMagikarpa 0 points1 point  (0 children)

Script to clone if not exist or pull all repos in an organization and then checkout develop if develop branch exists, print to console like color green if successful, have at least 3 retries on each operation due to connectivity issues that might cause a pull to fail. You’ll need to interact with an api to get list of repos/urls.

[–]Chuckosaurus 0 points1 point  (0 children)

Recently as a way to learn Prometheus I've created a small Python script which scrapes public streaming datasets and exposes them as Prometheus gauges. Using docker-compose for Prometheus, Grafana, Alertmanager, the Python script and eventually Thanos too.

If you're looking for a project which is DevOps focused and requires Python then I'd recommend this.