A discussion with a dear friend triggered the idea of this article. We discussed together how to automate the usage of chocolatey in azure to maintain the homogeneity of an IT environment while using an internal repository instead of fetching files each time from the internet.

Once I get back home; I started a POC on my Azure subscription. Hereafter a simplified architecture schema of my solution.

Basically, we have a chocolatey server hosted in a separate virtual network that has access to the internet so it can be able to download chocolatey packages. In a separate network the ansible server and our target servers on which we need to deploy packages using ansible.

Humm, it is simple and easy, isn’t it? Well, the answer is yes and no 🙂 I will explain in the coming sections of the article.

I suppose that you know how to deploy the virtual networks, network security group, resource group, and virtual machines. If not hereafter some links to help you achieve that:





Well enough documentation and let’s move to the installation of chocolatey server:

1- Install Chocolatey:

The installation is pretty easy, please check this link for pre-requisites.


And then run this code with administrative rights on Powershell.

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

2Install Choco.server

Now, installing the server version is pretty easy.


choco install chocolatey.server

Once the installation is done, you will be able to access the default page of the server using HTTP://[VM_IP]

In the next part of this article, I will continue discussing the deployment of Ansible, the configuration of the VM, and the execution of win_chocolatey. Stay tuned 🙂