-
Notifications
You must be signed in to change notification settings - Fork 171
/
create_ad_domain.yml
75 lines (66 loc) · 2.09 KB
/
create_ad_domain.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- name: Create Active Directory domain
hosts: "{{ _hosts | default('os_windows') }}"
gather_facts: false
tasks:
- name: Set Local Admin Password
ansible.windows.win_user:
name: Administrator
password: "{{ ansible_password }}"
- name: Create new domain in a new forest on the target host
ansible.windows.win_domain:
dns_domain_name: ansible.local
safe_mode_password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
notify:
- Reboot host
- Wait for AD services
- Reboot again
- Wait for AD services again
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Create some groups
community.windows.win_domain_group:
name: "{{ item.name }}"
scope: global
loop:
- name: "GroupA"
- name: "GroupB"
- name: "GroupC"
retries: 5
delay: 10
- name: Create some users
community.windows.win_domain_user:
name: "{{ item.name }}"
groups: "{{ item.groups }}"
password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}"
update_password: on_create
loop:
- name: "UserA"
groups: "GroupA"
- name: "UserB"
groups: "GroupB"
- name: "UserC"
groups: "GroupC"
retries: 5
delay: 10
handlers:
- name: Reboot host
ansible.windows.win_reboot:
reboot_timeout: 3600
- name: Wait for AD services
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10
- name: Reboot again
ansible.windows.win_reboot:
reboot_timeout: 3600
- name: Wait for AD services again
community.windows.win_wait_for_process:
process_name_exact: Microsoft.ActiveDirectory.WebServices
pre_wait_delay: 60
state: present
timeout: 600
sleep: 10