Install Chocolatey With Ansible On Windows Hosts

In this blog post, I will show you how to install Chocolatey on a Windows machine using Ansible and start deploying packages.

Managing Windows machines with Ansible is made possible through the use of WinRM, which allows Ansible to remotely execute commands on Windows machines.

Ansible provides modules specifically designed for managing Windows, enabling tasks such as installing and configuring software, managing system settings, and automating administrative tasks.

This allows for consistent and efficient management of Windows infrastructure alongside other operating systems in a unified manner, streamlining the management process for IT professionals.

About Chocolatey

Chocolatey is a package manager for Windows like apt for Ubuntu and yum for Centos.

Chocolatey is based on PowerShell and the part of it is that the entire installation process is done without using GUI or using screen prompts.

In my case, I will use the following playbook to install Chocolatey and Chocolate Core extensions, which are needed to install applications like Chrome, git, notepad ++ and many more, as you will see in the next few blog posts.

Install Chocolatey With Ansible On Windows Hosts

Below, is the complete playbook to install Chocolatey.

<div>
<pre>---
- name: "Chocolatey"
  hosts: windows
  tasks:
    - name: Install chocolatey
      win_chocolatey:
          name:
           - chocolatey
           - chocolatey-core.extension
          state: present