Tuesday, February 11, 2025

Ansible Lock user after 3 unsuccessful login attempt

 Hello Guys,

How to lock a user after 3 unsuccessful login attempt and after the cooldown time of 10 min the account get reactivated . we its a well establish windows command as well but when you have to do it on the large scale or you need to enforce it so that it never get overwritten we need automation for that and i know wrote a playbook for that which will make sure that.

- name: Set user lockout after 3 attempt
win_command: net accounts /lockoutthreshold:3
register: userLockout
args:
creates: C:\userLockout.lock

- name: Create userLockout.lock
win_copy:
dest: C:\userLockout.lock
content: ""
force: no
when: userLockout

- name: Set lockout duration to 10 min
win_command: net accounts /lockoutduration:10
register: lockduration
args:
creates: C:\lockduration.lock

- name: Create lockduration.lock
win_copy:
dest: C:\lockduration.lock
content: ""
force: no
when: lockduration

- name: Set reset the lockout timeout after 10 min
win_command: net accounts /lockoutwindow:10
register: lockoutwindow
args:
creates: C:\lockoutwindow.lock

- name: Create lockoutwindow.lock
win_copy:
dest: C:\lockoutwindow.lock
content: ""
force: no
when: lockoutwindow

No comments:

Post a Comment