Ansible on both Windows and Linux Systems

Ansible is an open-source automation tool that simplifies IT infrastructure provisioning, configuration management, and application deployment. It uses a declarative language called YAML (YAML Ain’t Markup Language) to define playbooks, which are sets of instructions that describe desired system states. Playbooks can be used to automate tasks on various operating systems, including Windows and Linux.

1. Install Ansible

To get started with Ansible on Windows and Linux, follow these steps:

On Linux: Ansible can be installed via package managers like `apt` or `yum`. For example, on Ubuntu, you can run:

sudo apt update
sudo apt install ansible

On Windows: Ansible can be installed using the Windows Subsystem for Linux (WSL) or by using a Docker container. WSL is recommended for better integration. Follow the instructions on the Ansible documentation for Windows installation.

2. Create an Inventory

The inventory file is a YAML or INI-formatted file that lists the target hosts you want to manage with Ansible. Create a file called `inventory` and define your hosts. For example:


Make sure to follow the YAML syntax guidelines, which include correct indentation using spaces (not tabs) and colons to separate keys from values.

3. Write a Playbook

Playbooks are written in YAML and consist of a series of plays, which contain tasks to be executed on hosts. Create a file called `playbook.yaml` and define your playbook. For example:

- name: Example Playbook
  hosts: all
    - name: Ensure NTP is installed
        name: ntp
        state: present
      become: true
      when: ansible_os_family == "Debian"

4. Execute the Playbook

To run the playbook, use the `ansible-playbook` command followed by the playbook filename and the inventory file. For example:

On Linux:

ansible-playbook -i inventory.yaml playbook.yaml

On Windows (using WSL):

ansible-playbook -i inventory.yaml playbook.yaml

Ansible offers a wide range of modules and features that you can explore further to automate complex tasks and manage your infrastructure efficiently.

Refer to the Ansible documentation for more detailed information and examples: [](

May 23, 2023
Was this article helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *