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:

  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.