Change local user password on Windows-like systems — Ansible module win_user

How to automate the password changing of the local user “example” on Windows-like systems using Ansible Playbook and module win_user.

Luca Berton


How to change user passwords on Windows-like systems with Ansible?

Password change is a mundane task that every System Administrator needs to perform regularly for your user base. Using Ansible you could simplify your workflow and maintain consistent your IT infrastructure fleet.

I’m going to show you a live demo with some simple Ansible code.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot,

Ansible changes local user password

  • ``
  • Manages local Windows user accounts

Today we’re talking about the Ansible module `win_user`.
The full name is ``, which means that is part of the collection of modules specialized to interact with Windows target host.
It’s a module pretty stable and out for years.
It works in Windows and Windows Server operating systems.
It manages local Windows user accounts.
For Linux target use the `user` module instead.


  • name string — user name
  • state string — present/absent
  • password string — cleartext password
  • update_password string — always / on_create

The only required is “name”, which is the user name.
The “state” parameter allows us to create or delete a user, in our use case the default it’s already set to “present” to create a user.
The “password” set the password in cleartext. So easily specify what password assign to the user, no hash function is needed.
The “update_password” parameter specifies when the module will update the user password. “always” option will update passwords if they differ, “on_create”…



Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday