mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-10 15:28:11 +07:00
78 lines
1.9 KiB
YAML
78 lines
1.9 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 }}"
|
|
register: iso
|
|
|
|
- name: Extract the ISO
|
|
command:
|
|
cmd: "7z x {{ iso.dest }} -o{{ role_path }}/build/mnt"
|
|
creates: "{{ role_path }}/build/mnt/.treeinfo"
|
|
|
|
- name: Extract bootloader
|
|
iso_extract:
|
|
image: "{{ role_path }}/build/mnt/images/efiboot.img"
|
|
dest: "{{ role_path }}/build/mnt/EFI/fedora"
|
|
files:
|
|
- EFI/fedora/grubx64.efi
|
|
|
|
- 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 machine specific Butane config
|
|
template:
|
|
src: http/ignition/ignition.yaml.j2
|
|
dest: "{{ role_path }}/build/http/ignition/{{ hostvars[item]['mac'] }}.yaml"
|
|
loop: "{{ groups['metal'] }}"
|
|
|
|
- name: Render Ignition config from Butane config
|
|
docker_container:
|
|
name: butane
|
|
image: quay.io/coreos/butane:release
|
|
auto_remove: yes
|
|
volumes:
|
|
- "{{ role_path }}/build/http/ignition:/local/src"
|
|
working_dir: /local/src
|
|
command:
|
|
- --pretty
|
|
- --strict
|
|
- "{{ hostvars[item]['mac'] }}.yaml"
|
|
- --output
|
|
- "{{ hostvars[item]['mac'] }}.json"
|
|
loop: "{{ groups['metal'] }}"
|
|
|
|
- name: Start ephemeral PXE server
|
|
docker_compose:
|
|
project_src: "{{ role_path }}/build"
|
|
state: present
|
|
restarted: yes
|
|
build: yes
|
|
recreate: always
|