mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-28 23:07:21 +00:00
Add user password reset and ability to disable an account
This commit is contained in:
1 parent
39722402f5
commit
2a4c00c015
8 files changed
+110
-49
No files matched your search
@@ -0,0 +1,80 @@
|
||||
---
|
||||
|
||||
- name: Check User Action
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- user_action is defined
|
||||
- user_action is string
|
||||
- user_action is in valid_actions
|
||||
quiet: true
|
||||
|
||||
- name: Check User information
|
||||
block:
|
||||
- name: Check Username
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- username is defined
|
||||
- username is string
|
||||
- username is not none
|
||||
- username|length <= 20
|
||||
quiet: true
|
||||
|
||||
- name: Check User Info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- study_code is defined
|
||||
- password is defined
|
||||
- firstname is defined
|
||||
- lastname is defined
|
||||
- email is defined
|
||||
- user_role is defined
|
||||
quiet: true
|
||||
when: user_action == 'create'
|
||||
|
||||
- name: Check Study folder & group
|
||||
block:
|
||||
- name: Check AD group exists
|
||||
win_domain_group:
|
||||
name: "{{ study_code }}"
|
||||
description: "{{ study_code }} study"
|
||||
path: "ou=Project Groups,dc={{ win_project }},dc=loc"
|
||||
scope: domainlocal
|
||||
category: security
|
||||
state: present
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: group
|
||||
failed_when: group.created == true
|
||||
|
||||
- name: Check if Folder Created
|
||||
win_stat:
|
||||
path: "{{ study_folder }}"
|
||||
register: folder
|
||||
delegate_to: "{{ os_project }}-{{ win_project }}-fs01"
|
||||
failed_when: folder.stat.exists == false
|
||||
|
||||
- name: Verify User
|
||||
block:
|
||||
- name: Get User account status
|
||||
win_domain_user:
|
||||
name: "{{ username }}"
|
||||
state: query
|
||||
register: user
|
||||
|
||||
- name: Check user doesn't already exist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- user.state == 'absent'
|
||||
msg: "Trying to create a user that already exists."
|
||||
quiet: true
|
||||
when: user_action == 'create'
|
||||
|
||||
- name: Check user exist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- user.state == 'present'
|
||||
msg: "Trying to modify a user that doesn't exists."
|
||||
quiet: true
|
||||
when: user_action != 'create'
|
||||
|
||||
|
||||
Reference in new issue
Block a user