Ansible · automation · Configuration management · FreeBSD automation

Installing and configuring Ansible 2.3 on FreeBSD 11

Apart from certain Linux distributions, Ansible also works with FreeBSD. Let’s have a look at how to install Ansible on FreeBSD 11.

In this article let’s assume the following details for the machines

Server – Hostname: server, IP :

Node1 – Hostname: node1, IP :

Node2 – Hostname: node2, IP :

Ansible is available through pkg. Install Ansible and Python using the following command.

pkg install ansible python

Ansible looks for Python in /usr/bin/ but is present in /usr/bin/local. So we’ll create a soft link for Python in /usr/bin

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

Generate ssh keypair on the Ansible server.


Do the following on nodes

Copy the public key of the server to all the nodes

cat .ssh/ (On Server to copy public key)

Append the public key copied from the server to .ssh/authorized_keys file on all the nodes

Once the keys have been copied we can check them by using the following commands on the server.

# ssh root@node-1
# ssh root@node-x

The above command should login directly and not wait for a password.

The ansible “hosts” file is present as a sample in /usr/local/share/examples/ansible/ directory. Copy that file to /usr/local/etc/ansible/

cp /usr/local/share/examples/ansible/hosts /usr/local/etc/ansible

Edit /usr/local/etc/ansible/hosts and append the following lines

node1 ansible_ssh_host=
node2 ansible_ssh_host=

Check the reachabilty of these nodes by using this following command

# ansible -m ping all


node2 | SUCCESS => {
"changed": false,
"ping": "pong"
node1 | SUCCESS => {
"changed": false,
"ping": "pong"

We can use another command to check a particular node.

ansible -m raw -a 'df' node1


node1 | SUCCESS | rc=0 >>
Filesystem  1K-blocks    Used   Avail Capacity  Mounted on
/dev/ada0p2  15224828 4909544 9097300    35%    /
devfs               1       1       0   100%    /dev
Shared connection to closed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s