mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 17:27:21 +00:00
Merge branch 'role/win_admin' into 'main'
Role/win admin See merge request win_automation/windows-ansible!7
This commit is contained in:
commit
7ba59fa98b
6 files changed
+70
No files matched your search
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- hosts: "meta-name_dc01"
|
||||||
|
gather_facts: false
|
||||||
|
vars_files:
|
||||||
|
- ../vars/common.yml
|
||||||
|
- ../vars/connection.yml
|
||||||
|
roles:
|
||||||
|
- role: win_admin
|
||||||
|
tags: win_admin
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
user_action: create
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Check User Action is valid
|
||||||
|
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 [CREATE]
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- password is defined
|
||||||
|
- firstname is defined
|
||||||
|
- lastname is defined
|
||||||
|
quiet: true
|
||||||
|
when: user_action == 'create'
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: Create AD Admin
|
||||||
|
block:
|
||||||
|
- name: Create user in AD
|
||||||
|
microsoft.ad.user:
|
||||||
|
name: "{{ username }}"
|
||||||
|
firstname: "{{ firstname }}"
|
||||||
|
surname: "{{ lastname }}"
|
||||||
|
groups:
|
||||||
|
add:
|
||||||
|
- "{{ domain_admin_group }}"
|
||||||
|
|
||||||
|
password: "{{ password }}"
|
||||||
|
password_expired: false
|
||||||
|
state: present
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Removing failed User
|
||||||
|
microsoft.ad.user:
|
||||||
|
name: "{{ username }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Trigger Failure
|
||||||
|
ansible.builtin.fail:
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- import_tasks: assert.yml
|
||||||
|
- import_tasks: "{{ user_action }}.yml"
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
valid_actions: ["create", "reset", "disable", "enable", "modify"]
|
||||||
|
domain_admin_group: "Domain Admins"
|
||||||
Reference in new issue
Block a user