Install Ansible on Windows, Linux, and MacOS
📦 Prerequisites
- Python 3.9 or later (except on Windows where WSL is recommended)
- Administrator or sudo privileges
- Internet connection
🪟 Windows (via WSL)
Ansible is not natively supported on Windows. Use Windows Subsystem for Linux (WSL).
- Enable WSL
wsl --install
:::info Restart your computer if prompted. :::
- Install a Linux distribution
- Open Microsoft Store and install Ubuntu (or another preferred distro).
- Launch Ubuntu from Start Menu
- Update packages
sudo apt update && sudo apt upgrade -y
- Install Ansible
sudo apt install software-properties-common -y
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
- Verify installation
ansible --version
🐧 Linux (Ubuntu/Debian)
- Update system
sudo apt update && sudo apt upgrade -y
- Install Ansible
sudo apt install software-properties-common -y
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
- Verify installation
ansible --version
🍎 macOS
- Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Ansible
brew install ansible
- Verify installation
ansible --version
✅ Post-Installation Tips
- Create an inventory file:
/etc/ansible/hostsor a custom one. - Test with:
ansible all -m ping -i your_inventory_file