Stop doing repeatable things, MAKE them automatic

The world without automation is a world full of repeatable work. Are you a type of a person who types [Up arrow] key in bash history multiple times to find a command, or a type of a person who puts all of his commands into scripts in context of given project?

Well, putting your commands even those daily ones into bash scripts, Makefiles or whatever is a first step in order to make things reproducible – DevOps wants everything to be reproducible, the things that are not reproducible are difficult to maintain, more to maintain is being more busy with a support tasks, not development of new solutions.

COMPOSE_ARGS=-f docker-compose.yml -f apps.www.yml -f infra.gateway.yml

    docker-compose ${COMPOSE_ARGS} up -d

    docker-compose ${COMPOSE_ARGS} down

First step, we automated mostly used commands, now we don’t need to type each time all of those switches and apply over, and over again the same file list. What’s next?

The second important rule is to maintain the scripts within a version control. Put your scripts into the git, so you will gain a backup, potential code review from your team and the transparency with others. It’s a good practice to keep the DevOps scripts together in one repository with developer’s project (if those scripts are related to the project) – you will always know where to find it.

„Anything that is not deployed from CI does not exists” – in organizations, where is more than one DevOps working together it is a very useful rule to remember. Mostly it applies to docker images, Kubernetes/OKD/compose/swarm/other environments. It is a very good practice to create a eg. Jenkins job that clones a repository and runs your scripts or Makefile, then archives the result and leaves the history of execution.

Going forward, maybe not to Make?

Doing so many automation gives you experience and working patterns, each time you create a new script or Makefile you start from doing similar things? It’s a probably sign of starting thinking about improving your way of structuring the code to share what is common.

It is difficult to keep all of those projects up-to-date with the current standard you are working on, second thing with Makefile and simple Bash scripts is about the complexity of solution advanced in time. Within months or years you will be adding more and more details to your scripts, maintaining it within a primitive tool will end up with a tons of hacks or duplicated instructions.

Example of a over-complicated Makefile:

Finding solution to duplicated and unclear scripts

Let’s pack our Makefile tasks into Python modules, let’s version them and install via Python’s PIP or from at least, let’s use command-line switches in place of global environment variables. At RiotKit we struggled to produce a tool that address those points, we created RiotKit-Do, in short – RKD.

What is RKD? It is a task executor where you can define tasks in a way you like to.

1) Write a Python class if you wish, pack it and publish to public or private repository.
2) Write a task in Python or Bash embedding it in a YAML file that looks like Makefile
3) Third option is a Makefile written in pure Python.

You have the choice and full control over task execution!