-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook-pxeserver.yml
188 lines (162 loc) · 4.29 KB
/
playbook-pxeserver.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
---
- name: Otus ansible
hosts: all
become: true
tasks:
- name: provisioner info
ansible.builtin.debug:
msg: "Hi otus -task 19 {{ inventory_hostname }}"
- name: Install a list of packages
ansible.builtin.yum:
name:
- wget
- epel-release
- httpd
- tftp-server
- dhcp-server
state: present
- name: create folder for images
file:
path: "{{ item }}"
state: directory
mode: 0755
loop:
- /images
- /iso
- name: Create a ext2 filesystem on /dev/sdb1
filesystem:
fstype: xfs
dev: /dev/sdb
- name: mount /dev/sdb to /images
mount:
path: /images
src: /dev/sdb
state: mounted
fstype: xfs
- name: make xfs on sdb
filesystem:
dev: /dev/sdc
fstype: xfs
- name: mount /dev/sdb to /images
mount:
path: /iso
src: /dev/sdc
state: mounted
fstype: xfs
- name: Change file ownership, group and permissions
ansible.builtin.file:
path: /iso
owner: vagrant
group: vagrant
mode: '0644'
- name: Mount ISO image
mount:
path: /mnt
src: /vagrant/CentOS-8.4.2105-x86_64-dvd1.iso
fstype: iso9660
opts: ro,loop
state: mounted
- name: copy /mnt to /iso
copy:
src: /mnt/
dest: /iso/
remote_src: true
force: yes
# directory_mode: yes
- name: start httpd
service:
name: httpd
enabled: true
state: started
- name: copy apache conf
template:
src: pxeboot.conf.j2
dest: /etc/httpd/conf.d/pxeboot.conf
owner: root
group: root
mode: '0640'
- name: restart httpd
service:
name: httpd
state: restarted
enabled: true
- name: start tftp
service:
name: tftp
enabled: true
state: started
#Создаём каталог /var/lib/tftpboot/pxelinux.cfg
- name: Create TFTP directory
file:
path: /var/lib/tftpboot/pxelinux.cfg
state: directory
mode: '0755'
#Копируем файл-меню на сервер
- name: set up pxelinux
template:
src: default
dest: /var/lib/tftpboot/pxelinux.cfg/default
owner: root
group: root
mode: '0644'
#Извлекаем файлы из RPM-пакета
- name: extract packages syslinux
shell: "rpm2cpio /iso/BaseOS/Packages/syslinux-tftpboot-6.04-5.el8.noarch.rpm | cpio -i -d"
#register: system_msg
# - name: Print uptime of managed node
# debug:
# msg: "{{ system_msg }}"
#Копируем файлы в каталог /var/lib/tftpboot/
- name: copy files to TFTP share
copy:
src: /home/vagrant/tftpboot/{{ item }}
dest: /var/lib/tftpboot/{{ item }}
mode: '0644'
remote_src: true
with_items:
- pxelinux.0
- ldlinux.c32
- libmenu.c32
- libutil.c32
- menu.c32
- vesamenu.c32
#Копируем файлы в каталог /var/lib/tftpboot/
- name: copy initrd and vmlinuz files to TFTP share
copy:
src: /iso/images/pxeboot/{{ item }}
dest: /var/lib/tftpboot/{{ item }}
mode: '0755'
remote_src: true
with_items:
- initrd.img
- vmlinuz
#Перезапускаем TFTP-сервер и добавляем его в автозагрузку
- name: restart tftp-server
service:
name: tftp.service
state: restarted
enabled: true
#Копирование файла конфигурации DHCP-сервера
- name: set up dhcp-server
template:
src: dhcpd.conf
dest: /etc/dhcp/dhcpd.conf
mode: '0644'
#Start dhcp-server
- name: start dhcp-server
service:
name: dhcpd
enabled: yes
state: started
- name: copy ks.cfg
template:
src: ks.cfg
dest: /iso/ks.cfg
owner: root
group: root
mode: 0755
- name: restart dhcpd
service:
name: dhcpd.service
state: restarted
enabled: true