Ivan Tomica

Using Ansible with FreeBSD

Using Ansible with FreeBSD as a managed node might not be straight forward as using some Linux distribution as, by default, FreeBSD doesn’t have Python interpreter installed which is needed for remote command execution in Ansible.

To bootstrap the FreeBSD host you first need to install python and needed dependencies with raw module:

ansible YOURHOST -m raw -a "pkg install -y python py27-simplejson"

This will provide you with Python interpreter, but since it is installed from package/ports it will be installed in /usr/local/bin/python while Ansible expects it to be in /usr/bin/python. To correct this misunderstanding you can either use following in your playbooks:

vars:
  ansible_python_interpreter: "/usr/local/bin/python"

Or you can simply create symlink:

ln -s /usr/local/bin/python /usr/bin/python

This is my preferred way of doing things so I don’t have to think about it anymore when writing my playbooks.

Tagged in:,
About 
Sysadmin on the everlasting journey of learning. Always in search for an opportunity to prove myself and to learn something new. My addiction is learning and my main goal is to excel in every aspect of Linux/Unix system administration.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *