mirror of
https://github.com/khuedoan/homelab.git
synced 2025-02-25 22:18:53 +07:00
New pxe server structure
No submodule and string replace script, j2 templates only
This commit is contained in:
parent
45e72a3d2b
commit
c2744838ab
@ -1 +0,0 @@
|
||||
Subproject commit a3a0e46aa64b30903d6caf394edc6d9d1e5e86da
|
11
metal/roles/pxe-server/files/dhcp/Dockerfile
Normal file
11
metal/roles/pxe-server/files/dhcp/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM alpine:3
|
||||
|
||||
RUN apk add dhcp gettext
|
||||
|
||||
RUN touch /var/lib/dhcp/dhcpd.leases
|
||||
|
||||
COPY dhcpd.conf /etc/dhcp/dhcpd.conf
|
||||
|
||||
COPY start.sh /start.sh
|
||||
|
||||
CMD [ "/start.sh" ]
|
27
metal/roles/pxe-server/files/docker-compose.yml
Normal file
27
metal/roles/pxe-server/files/docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
dhcp:
|
||||
build: ./dhcp
|
||||
network_mode: host
|
||||
environment:
|
||||
- SUBNET
|
||||
- NETMASK
|
||||
- GATEWAY
|
||||
- RANGE_START
|
||||
- RANGE_END
|
||||
- PXE_SERVER
|
||||
tftp:
|
||||
build: ./tftp
|
||||
network_mode: host
|
||||
environment:
|
||||
- PXE_SERVER
|
||||
volumes:
|
||||
- ./mnt:/mnt
|
||||
http:
|
||||
build: ./http
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./mnt:/usr/share/nginx/html/CentOS
|
||||
environment:
|
||||
NGINX_PORT: 80
|
9
metal/roles/pxe-server/files/http/Dockerfile
Normal file
9
metal/roles/pxe-server/files/http/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM nginx:1.19-alpine
|
||||
|
||||
RUN apk add gettext
|
||||
|
||||
COPY ./kickstart /usr/share/nginx/html/kickstart
|
||||
|
||||
COPY start.sh /start.sh
|
||||
|
||||
CMD [ "/start.sh" ]
|
10
metal/roles/pxe-server/files/tftp/Dockerfile
Normal file
10
metal/roles/pxe-server/files/tftp/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM alpine:3
|
||||
|
||||
RUN apk add tftp-hpa gettext
|
||||
|
||||
COPY grub.cfg /var/lib/tftpboot/grub.cfg
|
||||
|
||||
|
||||
COPY start.sh /start.sh
|
||||
|
||||
CMD [ "/start.sh" ]
|
@ -1,13 +1,13 @@
|
||||
# - name: Start PXE server
|
||||
# community.general.docker_compose:
|
||||
# project_src: "{{ role_path }}/files/pxe-servers"
|
||||
|
||||
- name: Download ISO
|
||||
get_url:
|
||||
url: "{{ iso_url }}"
|
||||
dest: "{{ role_path }}/files/images/"
|
||||
# - name: Download ISO
|
||||
# get_url:
|
||||
# url: "{{ iso_url }}"
|
||||
# dest: "{{ role_path }}/files/images/"
|
||||
|
||||
- name: Render environment file
|
||||
template:
|
||||
src: "{{ role_path }}/files/.env.j2"
|
||||
dest: "{{ role_path }}/files/.env"
|
||||
|
||||
- name: Start PXE server
|
||||
community.general.docker_compose:
|
||||
project_src: "{{ role_path }}/files/pxe-servers"
|
||||
|
53
metal/roles/pxe-server/templates/centos8.ks.j2
Normal file
53
metal/roles/pxe-server/templates/centos8.ks.j2
Normal file
@ -0,0 +1,53 @@
|
||||
%pre --interpreter=/bin/sh
|
||||
MAC=$(ip --brief link show dev $NETWORK_DEVICE | tr -s ' ' | cut -d ' ' -f 3 | sed 's/:/-/g')
|
||||
curl "http://$PXE_SERVER/kickstart/network/$MAC.ks" > /tmp/network.ks
|
||||
%end
|
||||
|
||||
#version=RHEL8
|
||||
ignoredisk --only-use=$DISK
|
||||
autopart --type=lvm
|
||||
# Partition clearing information
|
||||
clearpart --all --initlabel --drives=$DISK
|
||||
# Do not use graphical install
|
||||
text
|
||||
# Keyboard layouts
|
||||
keyboard --vckeymap=us --xlayouts='us'
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
|
||||
# Network information
|
||||
%include /tmp/network.ks
|
||||
repo --name="AppStream" --baseurl=http://$PXE_SERVER/CentOS/AppStream
|
||||
# Use network installation
|
||||
url --url="http://$PXE_SERVER/CentOS/"
|
||||
# Disable Setup Agent on first boot
|
||||
firstboot --disable
|
||||
# Do not configure the X Window System
|
||||
skipx
|
||||
# System services
|
||||
services --enabled="chronyd"
|
||||
# System timezone
|
||||
timezone Asia/Ho_Chi_Minh --isUtc
|
||||
|
||||
# Create user
|
||||
user --groups=wheel --name=$USERNAME --password=$ENCRYPTED_PASSWORD --iscrypted --gecos="$USERNAME"
|
||||
# Add SSH key
|
||||
sshkey --username=root "$SSH_PUBLIC_KEY"
|
||||
|
||||
%packages
|
||||
@^minimal-environment
|
||||
kexec-tools
|
||||
|
||||
%end
|
||||
|
||||
%addon com_redhat_kdump --enable --reserve-mb='auto'
|
||||
|
||||
%end
|
||||
|
||||
%anaconda
|
||||
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
||||
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
|
||||
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
|
||||
%end
|
||||
|
||||
reboot
|
20
metal/roles/pxe-server/templates/dhcpd.conf.j2
Normal file
20
metal/roles/pxe-server/templates/dhcpd.conf.j2
Normal file
@ -0,0 +1,20 @@
|
||||
option space pxelinux;
|
||||
option pxelinux.magic code 208 = string;
|
||||
option pxelinux.configfile code 209 = text;
|
||||
option pxelinux.pathprefix code 210 = text;
|
||||
option pxelinux.reboottime code 211 = unsigned integer 32;
|
||||
option architecture-type code 93 = unsigned integer 16;
|
||||
|
||||
subnet $SUBNET netmask $NETMASK {
|
||||
option routers $GATEWAY;
|
||||
range $RANGE_START $RANGE_END;
|
||||
|
||||
class "pxeclients" {
|
||||
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
|
||||
next-server $PXE_SERVER;
|
||||
|
||||
if option architecture-type = 00:07 {
|
||||
filename "grubx64.efi";
|
||||
}
|
||||
}
|
||||
}
|
5
metal/roles/pxe-server/templates/grub.cfg.j2
Normal file
5
metal/roles/pxe-server/templates/grub.cfg.j2
Normal file
@ -0,0 +1,5 @@
|
||||
set timeout=5
|
||||
menuentry 'CentOS' {
|
||||
linuxefi vmlinuz ip=dhcp inst.repo=http://$PXE_SERVER/CentOS ks=http://$PXE_SERVER/kickstart/centos8.ks
|
||||
initrdefi initrd.img
|
||||
}
|
2
metal/roles/pxe-server/templates/network.ks.j2
Normal file
2
metal/roles/pxe-server/templates/network.ks.j2
Normal file
@ -0,0 +1,2 @@
|
||||
network --bootproto=static --device=$NETWORK_DEVICE --ip=$IP --gateway=$GATEWAY --nameserver=$DNS --netmask=$NETMASK --ipv6=auto --activate
|
||||
network --hostname=$HOSTNAME
|
Loading…
Reference in New Issue
Block a user