homelab/metal/roles/pxe-server/tasks/main.yml
2022-05-12 23:15:51 +02:00

37 lines
943 B
YAML

- name: Download boot image
get_url:
url: "{{ os_download_url }}"
dest: "{{ role_path }}/files/data/source/netboot.tar.gz"
checksum: "{{ os_download_checksum }}"
register: netboot_tar
- name: Extract boot image
unarchive:
src: "{{ netboot_tar.dest }}"
dest: "{{ role_path }}/files/data/os"
- name: Generate DHCP config
template:
src: dhcpd.conf.j2
dest: "{{ role_path }}/files/data/pxe-config/dhcpd.conf"
mode: 0644
- name: Generate GRUB config
template:
src: grub.cfg.j2
dest: "{{ role_path }}/files/data/pxe-config/grub.cfg"
mode: 0644
- name: Generate preseed file for each machine
template:
src: preseed.cfg.j2
dest: "{{ role_path }}/files/data/preseed/{{ hostvars[item]['mac'] }}.cfg"
mode: 0644
loop: "{{ groups['metal'] }}"
- name: Start PXE stack
docker_compose:
project_src: "{{ role_path }}/files"
state: present
restarted: true
build: true