How to manage OpenBSD with Ansible


Ansible is an open source tool to perform application deployment and configuration management. Two of the advantages over other tools are:

This makes ansible pretty useful for home-network use.

Ansible with OpenBSD

While ansible doesn’t need an agent on the host to be managed, it does need Python. OpenBSD doesn’t ship with Python by default so we need to install it:

$ doas pkg_add python-2.7  

The installation process suggests to symlink the installed version to python, but this is not necessary if you only want to use it with ansible.

Now we only need to tell ansible where to find the Python executable and which method to use to become root.
This can easily be done with inventory variables and host groups. Create an openbsd group, to which all OpenBSD hosts belong to and declare the following variables:



Ansible also supports doas as become method, but I couldn’t get that to work properly.