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

73 lines
1.8 KiB
YAML
Raw Normal View History

- name: Create build directory
file:
path: "{{ item }}"
state: directory
loop:
- "{{ role_path }}/build"
- "{{ role_path }}/build/images"
- "{{ role_path }}/build/mnt"
2021-03-03 00:04:09 +07:00
# - name: Download ISO
# get_url:
# url: "{{ iso_url }}"
# dest: "{{ role_path }}/build/images/centos8.iso"
2021-02-12 20:12:42 +07:00
- name: Mount the ISO
mount:
2021-02-12 20:39:22 +07:00
src: "{{ role_path }}/build/images/centos8.iso"
2021-02-12 20:12:42 +07:00
path: "{{ role_path }}/build/mnt"
fstype: iso9660
opts: loop,ro
state: mounted
become: yes
2021-02-08 14:13:40 +07:00
- 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
2021-02-12 20:12:42 +07:00
docker_compose:
2021-02-12 20:39:22 +07:00
project_src: "{{ role_path }}/build"
build: yes
delegate_to: localhost
2021-03-03 00:04:09 +07:00
- name: Unconditionally shut down the machine with all defaults
community.general.shutdown:
delay: 0
- name: Wait for the machine to shutdown
wait_for:
timeout: 30
delegate_to: localhost
- name: Send magic Wake-on-LAN packet
community.general.wakeonlan:
mac: "{{ hostvars[inventory_hostname]['mac'] }}"
delegate_to: localhost
- name: Wait for the servers to comes up
wait_for_connection:
timeout: 600