Files
homework29/ansible.yml
2026-03-11 23:35:45 +03:00

125 lines
2.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
- hosts: pxe-server
become: true
vars:
network: 192.168.80.0
netmask: 255.255.255.0
range_ip_start: 192.168.80.50
range_ip_stop: 192.168.80.100
tftp_server: 192.168.80.30
tasks:
- name: update
apt:
update_cache: yes
- name: install dhcp-server, tftp-server, apache, syslinux, pxelinux
apt:
name:
- isc-dhcp-server
- tftp-server
- apache2
- syslinux
- pxelinux
state: present
- name: download ubuntu 24.04
get_url:
url: https://releases.ubuntu.com/noble/ubuntu-24.04.4-live-server-amd64.iso
#url: http://192.168.80.10/ubuntu-24.04.4-live-server-amd64.iso
dest: /var/www/html/ubuntu-24.04.iso
mode: 0755
timeout: 1000
- name: сreate dir mount for iso ubuntu
file:
path: /tmp/iso
state: directory
- name: mount ubuntu
mount:
src: /var/www/html/ubuntu-24.04.iso
path: /tmp/iso
state: mounted
fstype: iso9660
opts: loop,ro
- name: copy vmlinuz and initrd
copy:
src: /tmp/iso/casper/{{ item }}
dest: /srv/tftp/
remote_src: yes
loop:
- vmlinuz
- initrd
- name: copy PXE files
copy:
src: /usr/lib/syslinux/modules/bios/{{ item }}
dest: /srv/tftp/
remote_src: yes
loop:
- ldlinux.c32
- libcom32.c32
- libutil.c32
- vesamenu.c32
- name: copy lpxelinux
copy:
src: /usr/lib/PXELINUX/lpxelinux.0
dest: /srv/tftp/
remote_src: yes
- name: create conf lpxelinux dir
file:
path: /srv/tftp/pxelinux.cfg
state: directory
- name: copy template pxelinux conf
template:
src: pxelinux.template
dest: /srv/tftp/pxelinux.cfg/default
notify: restart tftp-hpa
- name: copy template dhcpd conf
template:
src: dhcpd.template
dest: /etc/dhcp/dhcpd.conf
notify: restart dhcpd
- name: сreate user-data http dir
file:
path: /var/www/html/autoinstall
state: directory
mode: 0755
- name: copy user-data
template:
src: user-data
dest: /var/www/html/autoinstall/user-data
mode: 0755
- name: сreate meta-data file
copy:
dest: /var/www/html/autoinstall/meta-data
content: ""
mode: 0755
handlers:
- name: restart dhcpd
systemd:
name: isc-dhcp-server
state: restarted
- name: restart tftp-hpa
systemd:
name: tftpd-hpa
state: restarted