Setting up Ansible on Debian 12.x

Just to go over briefly how to setup Ansible on Debian, here’s a few guidelines from my lab setup.

docs.ansible.com has the latest on the setup and it is what I followed. You don’t need the $ at the beginning of the lines, it’s simply shows you where there’s a new line. I have additionally added a line extral to show this more clearly (I hope).

$ UBUNTU_CODENAME=jammy
$ wget -O- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | sudo gpg --dearmour -o /usr/share/keyrings/ansible-archive-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu 

$UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/ansible.list
$ sudo apt update && sudo apt install ansible -y

Once these stepps are run you should have ansible installed on your host. You verify that by simply just running ansible –version. This should then give you an output like below:

Ansible installed 2.16
Ansible version 2.16 installed

Next part is to create folder structure and server groups. This is in general already documented here but for another project. So lets just create a couple of groups here.

For this setup I want all the linux servers in one group, the kubernetes master node in a group, the worker nodes in a group and all kubernetes in a group. Groups can be defined as IPs, hostnames or fqdn. Since we have dns here, I will use just the name of the servers since the domain name and search field are defined in resolv.conf we should be ok with that.

I included a part of the hosts file that shows how you can use group definitions and so on also. The groups I wanted are the ones in black.

ansible groups
Ansible groups

Before testing if it’s working, we need to generate some ssh keys. This is easily done with ssh-keygen and ssh-copy-id commands This is described here.

With that done, we can check the functionality of ansible in the test environment.

As we can see ansible is working fine with all the green success returns.

If we do one more test and instead of of the debian12 group goes for k8s-workers, then we get a smaller result because there’s only two nodes in the k8s-workers group:

k8s-worker-nodes-ping
Kubernetes worker nodes ping result

 

One last lil thing, you will most likely be needing python on your environment, and also pip3 and pvmomi.  These are things you tend to find yourself in need of using ansible from my experience.  To install these run the following commands:

sudo apt install python3-pip -y
sudo apt install python3-pyvmomi

To verify you can then run pip3 –version to verify the version is installed and also pip3 list to verify that you find pyvmomi installed.

python3 and pip verifications
Verification that Python3, pip3 and pyvmomi is installed

 

That’s about it for now on Ansible, we have an environment that is working.