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

38 lines
996 B
YAML
Raw Normal View History

2021-03-03 01:56:33 +07:00
- name: Download ISO
get_url:
url: "{{ iso_url }}"
2021-08-31 02:11:33 +07:00
dest: "{{ role_path }}/files/data/iso/{{ iso_url | basename }}"
checksum: "{{ iso_checksum }}"
register: iso
2021-03-03 01:25:56 +07:00
- name: Extract the ISO
2021-05-16 16:05:05 +07:00
command:
2021-08-31 02:11:33 +07:00
cmd: "xorriso -osirrox on -indev {{ iso.dest }} -extract / {{ role_path }}/files/data/os"
creates: "{{ role_path }}/files/data/os/.treeinfo"
2021-03-03 01:25:56 +07:00
- name: Render DHCP config
template:
2021-08-31 02:11:33 +07:00
src: dhcpd.conf.j2
2021-08-31 05:11:42 +07:00
dest: "{{ role_path }}/files/data/pxe-config/dhcpd.conf"
2021-12-26 12:12:36 +07:00
mode: 0644
2021-03-03 01:25:56 +07:00
- name: Render GRUB config
template:
2021-08-31 02:11:33 +07:00
src: grub.cfg.j2
2021-08-31 05:11:42 +07:00
dest: "{{ role_path }}/files/data/pxe-config/grub.cfg"
2021-12-26 12:12:36 +07:00
mode: 0644
2021-08-31 02:11:33 +07:00
- name: Render machine specific init config
template:
src: kickstart.ks.j2
dest: "{{ role_path }}/files/data/init-config/{{ hostvars[item]['mac'] }}.ks"
2021-12-26 12:12:36 +07:00
mode: 0644
2021-08-31 02:11:33 +07:00
loop: "{{ groups['metal'] }}"
2021-03-03 01:25:56 +07:00
- name: Start ephemeral PXE server
2021-03-03 01:25:56 +07:00
docker_compose:
2021-08-31 02:11:33 +07:00
project_src: "{{ role_path }}/files"
2021-03-03 01:25:56 +07:00
state: present
2021-12-26 12:12:36 +07:00
restarted: true
build: true