AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible Windows: Setup, WinRM Configuration & Automation Guide

By Luca Berton · Published 2024-01-01 · Category: installation

Complete guide to using Ansible with Windows. Install on WSL, configure WinRM, manage Windows hosts, and automate Windows servers with practical playbook.

Ansible is widely recognized for its ability to manage Linux systems, but can it run on Windows? The short answer is yes, with certain configurations. This article explores how Ansible works on Windows, its requirements, and how to set it up for automation workflows.

Can Ansible Run on Windows?

Ansible is primarily designed to run on Linux-based control nodes. However, with tools like the Windows Subsystem for Linux (WSL) or a virtual machine, it can run effectively on a Windows system. Ansible can also manage Windows target nodes directly using protocols like WinRM.

Key Points:

• Ansible cannot run natively on Windows as a control node. • Use WSL or a virtual machine for running Ansible on Windows systems. • Ansible can manage Windows systems as target nodes.

See also: Can Ansible Automate Windows? Complete WinRM + SSH Setup Guide (2026)

Setting Up Ansible on Windows Using WSL

Windows Subsystem for Linux (WSL) enables you to run a Linux environment directly on a Windows machine. Follow these steps to set up Ansible on Windows using WSL:

1. Install WSL

Open PowerShell as Administrator. Run the following command to install WSL:
   wsl --install
   
Restart your system if prompted.

2. Install a Linux Distribution

After installing WSL, choose a Linux distribution (e.g., Ubuntu) from the Microsoft Store.

3. Update and Install Ansible

Open the installed Linux distribution. Update the package manager:
   sudo apt update && sudo apt upgrade
   
Install Ansible:
   sudo apt install ansible -y
   

4. Verify Ansible Installation

Run the following command to check the Ansible version:
ansible --version

Running Ansible on Windows Using a Virtual Machine

Alternatively, you can set up a Linux virtual machine using tools like VirtualBox, VMware, or Hyper-V. Once the VM is running, install Ansible as you would on a native Linux system.

See also: Can Ansible Be Used to Manage Windows Systems?

Managing Windows Systems with Ansible

Ansible can manage Windows target systems using Windows Remote Management (WinRM). Follow these steps to configure a Windows system for management:

1. Enable WinRM

Open PowerShell as Administrator. Run the following commands:
   winrm quickconfig
   winrm set winrm/config/service/auth '@{Basic="true"}'
   winrm set winrm/config/service '@{AllowUnencrypted="true"}'
   Set-Item wsman:\localhost\Client\TrustedHosts -Value "<Ansible_Control_Node_IP>"
   

2. Install pywinrm on the Ansible Control Node

Install the pywinrm Python library for WinRM communication:
pip install pywinrm

3. Configure Ansible Inventory

Add the Windows system to your inventory file:
[windows]
windows_host ansible_host=192.168.1.10 ansible_user=Administrator ansible_password=your_password ansible_connection=winrm

4. Run a Playbook

Execute a playbook to manage the Windows system:
ansible-playbook -i inventory.ini playbook.yml

Best Practices for Running Ansible on Windows

Use WSL for Simplicity: WSL provides a lightweight and efficient way to run Ansible on Windows. Secure Communication: Use encrypted communication methods like HTTPS or Kerberos for WinRM. Test Configurations: Validate the setup in a test environment before deploying in production. Leverage Collections: Use Windows-specific collections like ansible.windows for pre-built modules.

See also: Can Ansible Manage Windows? Complete Windows Automation Guide

Conclusion

While Ansible cannot run natively on Windows as a control node, using tools like WSL or virtual machines makes it possible to run Ansible on a Windows machine effectively. Additionally, Ansible’s robust support for managing Windows target nodes ensures comprehensive automation capabilities across platforms.

Learn More About Ansible and Windows

Related Articles

Ansible inventory complete referencemanaging Windows hosts with Ansible

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home