Today, I wanted to mess around with Ansible on my Kali Linux machine. So, I figured I’d walk you guys through how I got it up and running. It’s not too tricky, but I took some notes along the way that I thought might be helpful for anyone else trying to do the same.
First things first, I had to get Ansible onto my system. Now, Kali is Debian-based, so we’re dealing with apt packages here. Before I could install Ansible, I made sure my system’s package list was up-to-date. I did that with a simple command:
sudo apt update
After updating the package list, I was ready to install Ansible. I ran:
sudo apt install ansible
This command fetched and installed Ansible along with its dependencies. The terminal showed a bunch of lines indicating what was being downloaded and installed. It took a few minutes, but I just waited for the process to complete.
- Then I got into checking if it installed all right. I just typed in ansible –version in my terminal and it spat back the version number. That was my cue that everything was good to go.
- Once Ansible was installed, I wanted to make sure it was properly set up. So, I decided to create a simple playbook and an inventory file.
- I created a new directory for my Ansible project and navigated into it.
- mkdir ansible-project
cd ansible-project - Inside this directory, I created an inventory file named hosts. This file tells Ansible which machines to manage. For now, I just added my localhost to it.
- echo “localhost ansible_connection=local” > hosts
- Next, I created a simple playbook named *. A playbook is a set of instructions for Ansible to execute.
- I opened the playbook in a text editor and added a basic task to ping my localhost.
- nano *
- The content of the playbook was as follows:
—
– hosts: all
become: true
tasks:
– name: Test ping
ping:
- With the playbook and inventory file in place, I ran the playbook using the ansible-playbook command.
- ansible-playbook -i hosts *
- The output showed that Ansible successfully connected to my localhost and executed the ping task. This confirmed that my Ansible setup was working correctly.
Wrap Up
Getting Ansible running on Kali Linux was pretty straightforward. Just a couple of commands to install it, a quick version check to make sure it’s there, and then I was good to start automating. I played around a bit more with it, testing out a few different commands, and it all seemed to work without a hitch. So, that’s my little adventure with Ansible on Kali for today. Hopefully, this helps some of you out there who are looking to do something similar.