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

63 lines
1.5 KiB
YAML
Raw Normal View History

2021-03-03 01:25:56 +07:00
- 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 }}/build/images"
- "{{ role_path }}/build/mnt"
2021-03-03 01:56:33 +07:00
- name: Download ISO
get_url:
url: "{{ iso_url }}"
dest: "{{ role_path }}/build/images/centos8.iso"
delegate_to: localhost
2021-03-03 01:25:56 +07:00
- name: Mount the ISO
mount:
src: "{{ role_path }}/build/images/centos8.iso"
path: "{{ role_path }}/build/mnt"
fstype: iso9660
opts: loop,ro
state: mounted
become: yes
- 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/centos8.ks.j2
dest: "{{ role_path }}/build/http/kickstart/centos8.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