Skip to content

Ansible Playbook to Create Windows Ansible User (bootstrap)

In my last post, I looked at setting up WinRM to give Ansible remote access in to a Windows computer. Presumably, one would use a regular administrative account to do so. However, there are some reasons a regular user account would be less desirable.

Namely, that in the Ansible hosts file, the password has to be there. Also, if one is using a Microsoft account (as Windows 10 nags about doing) or using a Domain account, the password also provides access to any Microsoft service or (respectively) to computer on the domain (not to mention domain services such as email, file access, etc)—not just the hosts Ansible is trying to connect to.

So, it would be better to have a dedicated account for Ansible’s use only. Ideally, one could push this account to Windows computers: that is, have Ansible create the Windows account (logging in once using existing credentials). Further Ansible processes could use the newly-created account.

I wrote an Ansible playbook to create this account, add it to the Administrators group, and then hide it (using registry settings) from the login screen:

Of course, the password above should be changed (but still set to a really long random character sequence).

One can then edit the host variables in your ansible hosts file to use the above created account.

Be the first to like.