Programming
Computer programming is essentially the beginning of it all (minus the electrical engineering aspects of course.)
Everything we're doing in DevOps is because of programming and software engineering. When some software is written we, in the operations side of DevOps, must deploy it. Because we're responsible for deploying software we have an obligation to understand some software development principles.
We're also going to need to understand how-to write and edit some programs so that we can automate some of the processes we'll develop during our career. The kind of programming we'll be doing in our space is simple enough (compared to the more complex software we use and deploy day to day) but it'll enable us to do some pretty powerful things.
To achieve this, we'll learn Python.
Note
Go is on the horizon too, but we'll get to that later on. It's quite advanced, so we'll leave it until we're doing some DevOps related tasks and building a platform.
Integrated Development Environment (IDE)
We suggest you download and learn how-to use a simple IDE called Visual Studio Code to learn how-to code. It's very popular, has loads of plugins, and you'll find it easy to get answers to your questions should you dump into problems.
Once installed, move onto getting Bash and Python installed and running on your local system.
Running Python
Before you go any further, you're going to need a way run Bash and Python. Installing either of these tools is very simple on macOS and Linux, but Windows makes the process a bit more long winded. We'll cover your options below.
Windows
When it comes to getting Python on Windows, it's quite easy, thankfully. All you need to do is install Python
using an official package and you're good to go. At the time of
writing, Python version 3.11.1 was released December 6th, 2022. Select the "Windows Installer (64-bit)" option:
Once installed, you'll be able to run cmd.exe (command line) or powershell.exe (Power Shell) and run python
commands.
macOS
Python is already present on macOS, but it may be Python 2, which was deprecated January 2021. You need to be using Python 3 now. The easiest way of doing this is to first install Homebrew and use it to install Python:
Note
And to be honest, Homebrew is a must on macOS. There's a good reason they call themselves the missing macOS package manager.
brew install python
Once that's complete, you can run python3 commands (note: not python.)
Linux
Python 3 is likely going to be present on your local flavour of Linux, but if not, you'll simply need to consult your desktop package manager and install what's missing.
Curated Materials
We've got a few resources and technologies for you to study in this section.
Python Virtual Environments
Before you get into learning Python itself, we suggest you learn about Python "Virtual Environments". They're not as complex as they sound, but they're important. In short: they're how you run and manage your code's dependencies without having to deal with the system-wide installation of Python and Python libraries.
For example, if you have some Python code that requires Python 3.2 (let's say), and it requires a library called
super-cool-library version 3.4.67, then updating the system-wide Python installation to include Python 3.2 and
this super-cool-library package can be done, but it could also break other Python code running on the same system.
To overcome this, we use Virtual Environments (venv), which give us a completely isolated, localised (to our code)
installation of Python, pip, and all the libraries we need.
All you need to read is the following sections of this "Real Python" tutorial series:
Note
Technically, you could stop here and move onto the rest of the curated content, but if you want to know more about Python venv, then we've included the below to give you that option.
- Why do you need virtual environment?
- "What Is a Python Virtual Environment?"
- "How Does a Virtual Environment Work?"
Everything else outside of these sections of the tutorial can be ignored.
Programming with Mosh
The best resource we've found is a video by Programming with Mosh. It's one hour long and is very well made. It's had nearly 10 million views on the YouTube and 250,000 likes. It's an excellent resource.
!!! note Mosh suggests using PyCharm as the IDE. You're welcome to give it a try, but we use Visual Studio Code throughout our content, so make sure you're prepared to switch from PyCharm to VSCode.
Another option
If video isn't your thing, then check out the Learn Python tutorial. This start at the "Hello, World!" example and progresses from there.
Once you're done with this video, we'll move onto some assessment code pieces, projects, and then I'm going to challange you to fix some broken code.
Optional Content
There's also some optional content you should be aware of. Mosh has made a complete Python course, over five hours, covering almost everything you can imagine. It also includes some cool projects. Feel free to check it out, but remember: don't go too deep into any topic. You only need the basics.
Data Formats
We also want you to understand a few data forms. These are used over and over throughout the industry, so you'll need to understand them fairly well. Being able to write documents in the following formats is an ideal skillset to have, but if you can at least read them and understand what's happening, then you're good to go.
They're not a programming languages!
Note that JSON, YAML, and XML are not programming languages. The below article from CloudBees states, "YAML Ain't Markup Language (YAML) is a data serialization language that is consistently listed as one of the most popular programming languages", but it's not a programming language.
These formats are primarily used to transmit data over a network connection. They're used extremely heavily in API calls, but with formats like JSON and YAML, they're also used a lot in the configuration of software.
Projects
Warning
Missing content.
Challenges
Warning
Missing content.