khuedoan-homelab/metal/roles/pxe-boot/tasks/server.yml

63 lines
1.5 KiB
YAML

- name: Gather network facts
ansible.builtin.setup:
gather_subset:
- network
- name: Create build directory
file:
path: "{{ item }}"
state: directory
loop:
- "{{ role_path }}/build"
- "{{ role_path }}/files/images"
- "{{ role_path }}/build/mnt"
- name: Download ISO
get_url:
url: "{{ iso_url }}"
dest: "{{ role_path }}/files/images/{{ iso_file_name }}"
checksum: "{{ iso_checksum }}"
delegate_to: localhost
register: iso
- name: Extract the ISO
command:
cmd: "xorriso -osirrox on -indev {{ iso.dest }} -extract / {{ role_path }}/build/mnt"
creates: "{{ role_path }}/build/mnt/.treeinfo"
- name: Copy configs
copy:
src: "{{ role_path }}/templates/"
dest: "{{ role_path }}/build"
- name: Render DHCP config
template:
src: dhcp/dhcpd.conf.j2
dest: "{{ role_path }}/build/dhcp/dhcpd.conf"
- name: Render GRUB config
template:
src: tftp/tftpboot/grub.cfg.j2
dest: "{{ role_path }}/build/tftp/tftpboot/grub.cfg"
- name: Render shared kickstart config
template:
src: http/kickstart/fedora.ks.j2
dest: "{{ role_path }}/build/http/kickstart/fedora.ks"
- name: Render seperate network kickstart config for each node
template:
src: http/kickstart/network/network.ks.j2
dest: "{{ role_path }}/build/http/kickstart/network/{{ hostvars[item]['mac'] }}.ks"
loop: "{{ groups['metal'] }}"
- name: Start PXE server
docker_compose:
project_src: "{{ role_path }}/build"
state: present
restarted: yes
build: yes
recreate: always
notify:
- Stop PXE server