Of late, this writer has been busy creating new virtual hosts for different things and decided that it would be an ideal time to get stuck into Ansible. Things have evolved in system management since Bash.
Ansible is a great way to deploy software configurations to servers and Linux machines in general. (Windows works, too, but with caveats.) It’s reliable, repeatable, easy to use and very extendable. And what you learn here can easily be expanded to work on remote machines.
We found ourselves building an Ansible configuration (aka a playbook) for our home desktops. That way, when the desktop needs rebuilding, it is as simple as a base install, install Ansible and run the playbook to put it back to just how you like it.
Ansible as a subject isn’t served well by diving into every part of it straight away, but looking at it bit by bit, as it’s needed, tends to work well. What follows is ‘just enough Ansible to be useful’ as an intro.
Why Ansible? Shell scripts still work but they can be clunky. Commands that would run to several lines in a shell script can replaced with just two lines in an Ansible playbook.
At the same time, Ansible offers consistency and is simple to understand. Sometimes Bash can become a bit gnarly.
PRO TIPS!
YAML can be extremely picky – spaces, not tabs, and so on. To help mitigate this issue, we suggest creating the YAML code in an editor that both understands YAML and offers syntax highlighting. This helps reduce those annoying errors that manifest themselves in strange Ansible execution errors.
Here’s another tip to avoid annoying ‘What have I done wrong here?’ scenarios. If there is nothing confidential in the YAML file, this checker can be very useful. If you are a bit confused as to why something isn’t working, ChatGPT can fix up those errors in seconds. It is such an amazing time-saver. Just use “As an expert in Ansible, what is wrong with this code?” and paste in the code. It promptly highlights and rectifies the problem. Most of our issues seem to be indentation-related!