Install .Net Framework 4.6.1 using Ansible


I’m trying to install .Net Framework 4.6.1 using Ansible but until now I have no luck.

I’ve tried those methods:

  1. Running a win_package to install it, but it just hangs till infinity
  2. Run a PowerShell script to install it (first doesn’t work and second throws stack-overflow exception):

  3. I’ve tried to use win_feature to install it, but it just do nothing.
  4. Tried to run a batch script to install it, but no luck:

Has anyone succeeded installing .Net Framework 4.6.1 using Ansible?

Could anyone share their task/role that installs it?


We were calling Chocolatey via Ansible to install .NET 4.6.1, but ran into some complications with that. Instead I rewrote our playbook to do a “native” install. I imagine you ran into the same issues I did with trying to run the offline installer. This led me to your post and this thread. Here is what I had to do to get it working.

Extract the contents of the offline installer:

This command can uninstall .NET if it is already installed. I just ran it on a fresh vagrant VM instead of trying to get around that.

Zip up the contents of that folder, upload it to an internal host or network share, and then download/unzip/run it with your playbook.

The arguments in the install command are important otherwise the installer will fail. You might be able to remove “/log C:\tmp\dotnet\dotnet461\log.txt”, but I’ll leave it to you to test that out 😀

Also this is not idempotent. The installer will execute every time. You can get around that by putting these tasks in a separate .yml file and doing a conditional include based on a registry check to see if it is installed.

Like this:

Leave a Reply