Ansible Installation
Ansible is a powerful automation platform for configuration management, application deployment, and orchestration that youβll use extensively in HackerOps labs.
Info
Pre-configured VMs: Ansible is already installed on the HackerOps Ubuntu VMs. Skip this guide if using the pre-configured environment.
What is Ansible?
Ansible allows you to:
- Automate server configuration without agents
- Deploy applications consistently across environments
- Orchestrate complex workflows with playbooks
- Manage cloud resources alongside Terraform
Official Documentation: Ansible Installation Guide
Installation Methods
Using Official PPA (Recommended):
# Update package indexsudo apt update
# Install prerequisitessudo apt install software-properties-common -y
# Add Ansible PPAsudo apt-add-repository --yes --update ppa:ansible/ansible
# Install Ansiblesudo apt updatesudo apt install ansible -y
# Verify installationansible --version
Alternative - Using pip:
# Install pip if not availablesudo apt updatesudo apt install python3-pip -y
# Install Ansiblepip3 install ansible
Using Homebrew (Recommended):
# Install Ansiblebrew install ansible
# Verify installationansible --version
Alternative - Using pip:
# Install pip if neededpython3 -m pip install --user pipxpython3 -m pipx ensurepath
# Install Ansiblepipx install ansible
Info
Requirement: Ansible requires a Unix/Linux environment. On Windows, use WSL or the pre-configured VM.
Option 1: Use WSL (Recommended)
If you already have WSL set up (see Ubuntu guide):
# In your WSL Ubuntu environmentsudo apt updatesudo apt install software-properties-common -ysudo apt-add-repository --yes --update ppa:ansible/ansiblesudo apt updatesudo apt install ansible -y
# Verify installationansible --version
Option 2: Use Python pip
# Install Python first, then use pippip install ansible
# Verify installationansible --version
Verify Installation
After installation, verify Ansible is working:
# Check versionansible --version
# Should output something like:# ansible [core 2.14.0]
Basic Usage Test
Test your installation with a simple ping:
# Test local connectionansible localhost -m ping
# Should output:# localhost | SUCCESS => {# "changed": false,# "ping": "pong"# }
Tip
Success! If you see βpongβ in the response, Ansible is properly installed and ready for the labs.
Next Steps
With Ansible installed:
- Set up cloud platforms - Configure AWS, Azure, and DigitalOcean
- Start Lab 1 - Begin with infrastructure automation
- Learn Ansible basics - Practice with playbooks in the labs
Troubleshooting
Command not found:
- Restart your terminal after installation
- Check if Ansible is in your PATH:
echo $PATH
- Try reinstalling using pip:
pip3 install ansible
Permission errors:
- Use
sudo
for Ubuntu package installations - On macOS, try:
brew doctor
to check Homebrew setup
Python errors:
- Ensure Python 3.6+ is installed:
python3 --version
- Update pip:
python3 -m pip install --upgrade pip