Tools

Tools and libraries I LOVE,… most of the time,… most of them: pytest ansible molecule tox pip pbr pre-commit black flake8 git-review Cross-platform GUI apps Visual Studio Code - we can no longer say that Microsoft is not able to provide a good IDE. Atom was good, but code is great. Beyond Compare - best ever diff tool. MacOS specific apps iTerm – version 3.3 is even more awesome than ever, I really need to write about it.

Using a remote docker

Whatever if you are using an operating system that does not support docker or you do not want overload your main desktop with docker service you should know that there is a very easy way of doing it. Docker added remoting support via ssh few years back but they missed to advertise it others. Mainly you can build and run containers on a remote host almost identically as you would do with a local one.

Mastering YAML

While YAML may seem to be a very simple file format it also hides a serious amount of complexity, one that is poorly documented. That is my attempt to clarify few of these things.

Ansible Cheatsheet

Variable precendence order Order, order please! command line values (eg “-u user”) role defaults inventory file or script group vars inventory group_vars/all playbook group_vars/all inventory group_vars/* playbook group_vars/* inventory file or script host vars inventory host_vars/* playbook host_vars/* host facts / cached set_facts play vars play vars_prompt play vars_files role vars (defined in role/vars/main.yml) block vars (only for tasks in block) task vars (only for the task) include_vars set_facts / registered vars role (and include_role) params include params extra vars (always win precedence) Load distro specific variables - name: Load operating system specific variables include_vars: "{{ item }}" failed_when: false loop: - "family-{{ ansible_os_family | lower }}.

Bash 101

Bash strict mode One of my top favorite articles around base is unofficial-bash-strict-mode and I recommend anyone to read it in order to understand why they should start every new shell script with that line below, even if they plan to write only a couple of commands. {% code title=“bash-seed.sh” %} #!/usr/bin/env bash set -euo pipefail # Or during development set -euxo pipefail {% endcode %} {% hint style=“info” %} There are some gotchas regarding using the magic strict mode.

Lint via pre-commit tool

As a developer I always found annoying to have to wait a long minutes or hours in order to get a CI build failure caused by some linting errors. Or those cases where you spot the errors in commit message after you push. On the other hand, running linters and unit-tests before making any contribution is usually included in the documentation. We do know very well that we often forget to do it.

Mastering Molecule

Controlling verbosity Few things you may need to master quickly while working with molecule scenarios: how to control verbosity of different actions. # disable nologs export MOLECULE_NOLOG=0 # disable destroy export MOLECULE_DESTROY=never # debug mode (same as --debug) -- very verbose export MOLECULE_DEBUG=1 # change ansible own verbosity export ANSIBLE_VEBOSITY=2 Passing Ansible arguments In the end, molecule will call Ansible for testing your code but this does not mean that you cannot add your own options.