Managing Windows machines with Ansible

An alternative way to configure Windows computers remotelly without an Active Directory

Xabi
The Sysadmin
2 min readNov 29, 2016

--

Starting in version 1.7, Ansible contains support for managing Windows machines. This guide describes the steps you need to follow to set it up.

Ansible makes Windows automating easier (source)

Windows preparation

In order for Ansible to manage your windows machines, you will have to enable and configure PowerShell remoting. Fortunately, there is a quick way to do that.

In your Windows machine, open a command prompt as Administrator and run the following command:

Note: Kaspersky Endpoint Security 10 uses its own firewall. You might change the configuration manually to allow WinRM incoming connections (TCP/5986)

Ansible control machine

Reminder: you must have a Linux Control Machine. There is no way to do that from a Windows host.

Instructions

You need to create the following directories/files structure:

hosts file
Add your Windows hosts to the inventory:

Under the group_vars directory, add the following file named windows.yml, where my_user/my_pass are the credentials you will use to log in the Windows computers:

That’s all. Now you can test it using the win_ping module:

More examples

Gather facts using setup module:

Installing Firefox with Chocolatey:

And finally, a funny one! Speak messages and play sounds using win_say module:

Do you want more? Check available Windows modules

--

--