Skip to content

Commit

Permalink
Disabling accounts before reboot & remove in accounts to avoid them…
Browse files Browse the repository at this point in the history
… being used before removal is complete
  • Loading branch information
AllRWeak authored and bl0way committed Mar 1, 2024
1 parent 8e6b664 commit d8662f1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nova/core/roles/accounts/tasks/windows_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
ansible.builtin.set_fact:
local_users_to_remove: "{{ user_profiles.stdout_lines | difference(local_accounts_list | map(attribute='username')) }}"

# This is to block any logins after reboot
- name: Disabling following local accounts...
ansible.windows.win_user:
name: "{{ item }}"
account_disabled: true
loop: "{{ local_users_to_remove }}"

- name: Rebooting to clear any open sessions...
ansible.windows.win_reboot:
when: local_users_to_remove != []
Expand Down Expand Up @@ -41,6 +48,13 @@
- name: Reboot and availability check...
when: domain_users_to_remove != []
block:
# This is to block any logins after reboot
- name: Disabling following domain accounts...
microsoft.ad.user:
name: "{{ item }}"
enabled: false
loop: "{{ domain_users_to_remove }}"

- name: Rebooting to close any open sessions...
ansible.windows.win_reboot:

Expand Down

0 comments on commit d8662f1

Please sign in to comment.