-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
122 lines (94 loc) · 2.57 KB
/
main.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
- name: SambaAD Setup
hosts: all
become: yes
vars:
ansible_become_pass: "Den2034Dns"
vars_files:
- defaults/main.yml
tasks:
- name: Ensure localhost is defined in /etc/hosts
lineinfile:
path: /etc/hosts
line: "127.0.0.1 localhost"
state: present
- name: Ensure domain controller is defined in /etc/hosts
lineinfile:
path: /etc/hosts
line: "{{ip}} {{hostname}}"
state: present
- name: Set the hostname
hostname:
name: "{{ hostname }}"
become: yes
- name: Insert DNS
blockinfile:
path: /etc/systemd/resolved.conf
block: |
[Resolve]
DNS={{ip}} {{dns}}
Domains={{search}}
marker: "# {mark} ANSIBLE MANAGED BLOCK"
become: yes
- name: Reload systemd manager configuration
command: systemctl daemon-reload
- name: Restart systemd-resolved service
systemd:
name: systemd-resolved
state: restarted
- name: Установка необходимых пакетов
apt:
name:
- acl
- attr
- samba
- winbind
- libpam-winbind
- libnss-winbind
- krb5-config
- krb5-user
- dnsutils
- python3-setproctitle
state: present
update_cache: yes
become: yes
- name: Configure /etc/krb5.conf
template:
src: templates/krb5.conf.j2
dest: /etc/krb5.conf
notify: Restart Kerberos
become: yes
- name: Disable and stop services
systemd:
name: "{{ item }}"
enabled: no
state: stopped
loop:
- smbd
- nmbd
- winbind
become: yes
- name: Unmask samba-ad-dc
file:
path: /etc/systemd/system/samba-ad-dc.service
state: absent
become: yes
- name: Reload systemd daemon
systemd:
daemon_reload: yes
become: yes
- name: Activate samda-ad-dc
systemd:
name: samba-ad-dc
state: started
enabled: yes
become: yes
- name: Remove /etc/samba/smb.conf
file:
path: /etc/samba/smb.conf
state: absent
become: yes
- name: create_domain | configuring Active Directory
shell: "samba-tool domain provision --realm={{ samba_realm | upper }} --domain={{ netbios_domain_name | upper }} --adminpass='{{ adminpass }}' --server-role='domain controller' --use-rfc2307"
become: true
register: samba_ad_created