aboutsummaryrefslogtreecommitdiffstats
path: root/roles/pxe_server/templates
diff options
context:
space:
mode:
authorStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:23:43 -0500
committerStonewall Jackson <stonewall@sacredheartsc.com>2023-02-04 01:52:13 -0500
commit0261e875679f1bf63c8d689da7fc7e014597885d (patch)
tree3f19cd74a0c1070944f75437f30b098d6ef2ffcb /roles/pxe_server/templates
downloadselfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.tar.gz
selfhosted-0261e875679f1bf63c8d689da7fc7e014597885d.zip
initial commit
Diffstat (limited to 'roles/pxe_server/templates')
-rw-r--r--roles/pxe_server/templates/grub/grub.cfg.j222
-rw-r--r--roles/pxe_server/templates/grub/menuentry-redhat.cfg.j218
-rw-r--r--roles/pxe_server/templates/kickstart/rocky8-ks.cfg.j289
3 files changed, 129 insertions, 0 deletions
diff --git a/roles/pxe_server/templates/grub/grub.cfg.j2 b/roles/pxe_server/templates/grub/grub.cfg.j2
new file mode 100644
index 0000000..ae2d7cb
--- /dev/null
+++ b/roles/pxe_server/templates/grub/grub.cfg.j2
@@ -0,0 +1,22 @@
+set timeout=-1
+
+if [ "$grub_cpu" = "x86_64" -a "$grub_platform" = "efi" ]; then
+ set linux=linuxefi
+ set initrd=initrdefi
+ export linux
+ export initrd
+fi
+
+{% for image in pxe_images %}
+if [ "$grub_cpu" = "{{ image.arch }}" ]; then
+ menuentry "{{ image.description }} {{ image.version }}" {
+ configfile "$prefix/{{ image.name }}-{{ image.version }}-{{image.arch }}.cfg"
+ }
+
+ {% for kickstart in image.kickstart | default([]) %}
+ menuentry "{{ image.description }} {{ image.version }}: {{ kickstart.description }}" {
+ configfile "$prefix/{{ image.name }}-{{ image.version }}-{{image.arch }}-{{ kickstart.name | splitext | first }}.cfg"
+ }
+ {% endfor %}
+fi
+{% endfor %}
diff --git a/roles/pxe_server/templates/grub/menuentry-redhat.cfg.j2 b/roles/pxe_server/templates/grub/menuentry-redhat.cfg.j2
new file mode 100644
index 0000000..f7dc2ac
--- /dev/null
+++ b/roles/pxe_server/templates/grub/menuentry-redhat.cfg.j2
@@ -0,0 +1,18 @@
+echo "{{ image.description }} {{ image.version }} ({{ image.arch }})"
+{% if kickstart is defined %}
+echo "kickstart: {{ kickstart.name }}"
+{% endif %}
+
+echo "loading kernel..."
+linux (http,${net_default_server}:{{ pxe_http_port }})/{{ image.name }}/{{ image.version }}/{{ image.arch }}/{{ image.kernel }} \
+ ip=dhcp \
+ inst.repo=http://${net_default_server}:{{ pxe_http_port }}/{{ image.name }}/{{ image.version }}/{{ image.arch }}/ {%- if kickstart is defined %} \
+ inst.ks=http://${net_default_server}:{{ pxe_http_port }}/kickstart/{{ kickstart.name }}
+ {%- endif %}
+
+
+echo "loading initrd..."
+initrd (http,${net_default_server}:{{ pxe_http_port }})/{{ image.name }}/{{ image.version }}/{{ image.arch }}/{{ image.initrd }}
+
+echo "booting linux..."
+boot
diff --git a/roles/pxe_server/templates/kickstart/rocky8-ks.cfg.j2 b/roles/pxe_server/templates/kickstart/rocky8-ks.cfg.j2
new file mode 100644
index 0000000..ddbb0f0
--- /dev/null
+++ b/roles/pxe_server/templates/kickstart/rocky8-ks.cfg.j2
@@ -0,0 +1,89 @@
+%pre --interpreter=/bin/bash
+set -Eeu -o pipefail
+
+# get the primary interface name
+interface=$(ip route list default | cut -d' ' -f5)
+
+# parse DHCP lease info
+declare -A dhcp
+while IFS= read -r line; do
+ dhcp["${line%% =*}"]=${line#*= }
+done <<< $(nmcli --terse --fields dhcp4 device show "$interface" | cut -d: -f2-)
+
+# configure interface for DHCP
+printf 'network --bootproto=dhcp --device=%q --hostname=%q --onboot=yes --noipv6\n' \
+ "$interface" \
+ "${dhcp[host_name]:-rocky-kickstart}" \
+ > /tmp/network.ks
+
+# if ntp-server was specified by DHCP server, use it
+if [ -n "${dhcp[ntp_servers]:-}" ]; then
+ printf 'timezone %q --utc --ntpservers=%q\n' \
+ {{ timezone | quote }} \
+ "${dhcp[ntp_servers]}" \
+ > /tmp/timezone.ks
+else
+ printf 'timezone %q --utc\n' {{ timezone | quote }} > /tmp/timezone.ks
+fi
+%end
+
+
+# installer configuration
+cmdline
+eula --agreed
+reboot
+
+
+# system configuration
+firstboot --disabled
+firewall --disabled
+keyboard --vckeymap=us
+lang {{ locale }}
+rootpw --iscrypted {{ root_password | password_hash("sha512", root_password_salt | default("")) }}
+selinux --disabled
+skipx
+
+{% for pubkey in root_authorized_keys %}
+sshkey --username=root "{{ pubkey }}"
+{% endfor %}
+
+
+# network
+%include /tmp/network.ks
+
+
+# timezone
+%include /tmp/timezone.ks
+
+
+# storage
+autopart --type=lvm --fstype=xfs --nohome
+bootloader --boot-drive=vda --location=mbr --timeout=3
+clearpart --drives=vda --all --initlabel
+zerombr
+
+
+# packages
+%packages
+@^minimal-environment
+-plymouth
+-iwl100-firmware
+-iwl1000-firmware
+-iwl105-firmware
+-iwl135-firmware
+-iwl2000-firmware
+-iwl2030-firmware
+-iwl3160-firmware
+-iwl5000-firmware
+-iwl5150-firmware
+-iwl6000-firmware
+-iwl6000g2a-firmware
+-iwl6050-firmware
+-iwl7260-firmware
+%end
+
+
+# disable kernel crashdumps
+%addon com_redhat_kdump --disable
+
+%end