khuedoan-homelab/metal/roles/pxe_server/tasks/main.yml

48 lines
1.5 KiB
YAML

- name: Get Docker info
docker_host_info: {}
register: docker_info_result
- name: Ensure Docker is running on a supported operating system
fail:
msg: Docker host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac or Windows (you can use a Linux VM with bridged networking instead)
when:
- docker_info_result.host_info.OperatingSystem == "Docker Desktop"
- name: Download boot image
ansible.builtin.get_url:
url: "{{ iso_url }}"
dest: "{{ role_path }}/files/data/iso/{{ iso_url | basename }}"
checksum: "{{ iso_checksum }}"
mode: 0644
register: iso
- name: Extract boot image
ansible.builtin.command:
cmd: "xorriso -osirrox on -indev {{ iso.dest }} -extract / {{ role_path }}/files/data/os"
creates: "{{ role_path }}/files/data/os/.treeinfo"
- name: Generate dnsmasq config
ansible.builtin.template:
src: dnsmasq.conf.j2
dest: "{{ role_path }}/files/data/pxe-config/dnsmasq.conf"
mode: 0644
- name: Generate GRUB config
ansible.builtin.template:
src: grub.cfg.j2
dest: "{{ role_path }}/files/data/pxe-config/grub.cfg"
mode: 0644
- name: Generate init config for each machine
ansible.builtin.template:
src: kickstart.ks.j2
dest: "{{ role_path }}/files/data/init-config/{{ hostvars[item]['mac'] }}.ks"
mode: 0644
loop: "{{ groups['metal'] }}"
- name: Start the ephemeral PXE server
community.docker.docker_compose_v2:
project_src: "{{ role_path }}/files"
state: present
build: always