Merge "ironic: make tftpboot and httpboot paths configurable"

This commit is contained in:
Zuul 2022-04-06 10:28:43 +00:00 committed by Gerrit Code Review
commit 3f243ff999
4 changed files with 33 additions and 24 deletions

View File

@ -43,7 +43,9 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
{% endif %}
COPY tftp-map-file /map-file
ENV TFTPBOOT_PATH=/tftpboot \
HTTPBOOT_PATH=/httpboot
COPY tftp-map-file-template /map-file-template
COPY extend_start.sh /usr/local/bin/kolla_ironic_extend_start
RUN chmod 755 /usr/local/bin/kolla_ironic_extend_start

View File

@ -3,14 +3,16 @@
# For x86 legacy BIOS boot mode
function prepare_pxe_pxelinux {
chown -R ironic: /tftpboot
for pxe_file in /var/lib/tftpboot/pxelinux.0 /var/lib/tftpboot/chain.c32 /usr/lib/syslinux/pxelinux.0 \
/usr/lib/syslinux/chain.c32 /usr/lib/PXELINUX/pxelinux.0 \
/usr/lib/syslinux/modules/bios/chain.c32 /usr/lib/syslinux/modules/bios/ldlinux.c32; do
if [[ -e "$pxe_file" ]]; then
cp "$pxe_file" /tftpboot
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
cp /usr/lib/PXELINUX/pxelinux.0 \
/usr/lib/syslinux/modules/bios/{chain.c32,ldlinux.c32} \
${TFTPBOOT_PATH}/
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos ]]; then
if [[ "${TFTPBOOT_PATH}" != /tftpboot ]]; then
cp /tftpboot/{pxelinux.0,chain.c32,ldlinux.c32} \
${TFTPBOOT_PATH}/
fi
done
fi
}
# For UEFI boot mode
@ -18,7 +20,7 @@ function prepare_pxe_grub {
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
shim_src_file="/usr/lib/shim/shim*64.efi.signed"
grub_src_file="/usr/lib/grub/*-efi-signed/grubnet*64.efi.signed"
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos|rhel ]]; then
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos ]]; then
shim_src_file="/boot/efi/EFI/centos/shim*64.efi"
grub_src_file="/boot/efi/EFI/centos/grub*64.efi"
fi
@ -31,8 +33,8 @@ function prepare_pxe_grub {
grub_dst_file="grubaa64.efi"
fi
cp $shim_src_file /tftpboot/$shim_dst_file
cp $grub_src_file /tftpboot/$grub_dst_file
cp $shim_src_file ${TFTPBOOT_PATH}/$shim_dst_file
cp $grub_src_file ${TFTPBOOT_PATH}/$grub_dst_file
}
function prepare_ipxe {
@ -41,21 +43,21 @@ function prepare_ipxe {
# was ipxe.efi. Ensure that both exist, using symlinks where the files are
# named differently to allow the original names to be used in ironic.conf.
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
cp /usr/lib/ipxe/{undionly.kpxe,ipxe.efi} /tftpboot
cp /usr/lib/ipxe/{undionly.kpxe,ipxe.efi} ${TFTPBOOT_PATH}/
# NOTE(mgoddard): The 'else' can be removed when snponly.efi is
# available in Jammy 22.04.
if [[ -f /usr/lib/ipxe/snponly.efi ]]; then
cp /usr/lib/ipxe/snponly.efi /tftpboot/snponly.efi
elif [[ ! -e /tftpboot/snponly.efi ]]; then
ln -s /tftpboot/ipxe.efi /tftpboot/snponly.efi
cp /usr/lib/ipxe/snponly.efi ${TFTPBOOT_PATH}/snponly.efi
elif [[ ! -e ${TFTPBOOT_PATH}/snponly.efi ]]; then
ln -s ${TFTPBOOT_PATH}/ipxe.efi ${TFTPBOOT_PATH}/snponly.efi
fi
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos ]]; then
cp /usr/share/ipxe/{undionly.kpxe,ipxe*.efi} /tftpboot
if [[ ! -e /tftpboot/ipxe.efi ]]; then
ln -s /tftpboot/ipxe-${KOLLA_BASE_ARCH}.efi /tftpboot/ipxe.efi
cp /usr/share/ipxe/{undionly.kpxe,ipxe*.efi} ${TFTPBOOT_PATH}/
if [[ ! -e ${TFTPBOOT_PATH}/ipxe.efi ]]; then
ln -s ${TFTPBOOT_PATH}/ipxe-${KOLLA_BASE_ARCH}.efi ${TFTPBOOT_PATH}/ipxe.efi
fi
if [[ ! -e /tftpboot/snponly.efi ]]; then
ln -s /tftpboot/ipxe-snponly-${KOLLA_BASE_ARCH}.efi /tftpboot/snponly.efi
if [[ ! -e ${TFTPBOOT_PATH}/snponly.efi ]]; then
ln -s ${TFTPBOOT_PATH}/ipxe-snponly-${KOLLA_BASE_ARCH}.efi ${TFTPBOOT_PATH}/snponly.efi
fi
fi
}
@ -63,10 +65,15 @@ function prepare_ipxe {
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
mkdir -p ${TFTPBOOT_PATH} ${HTTPBOOT_PATH}
chown ironic: ${TFTPBOOT_PATH} ${HTTPBOOT_PATH}
prepare_pxe_pxelinux
prepare_pxe_grub
prepare_ipxe
exit 0
fi
# Template out a TFTP map file, using the TFTPBOOT_PATH variable.
envsubst < /map-file-template > /map-file
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,4 +0,0 @@
re ^(/tftpboot/) /tftpboot/\2
re ^/tftpboot/ /tftpboot/
re ^(^/) /tftpboot/\1
re ^([^/]) /tftpboot/\1

View File

@ -0,0 +1,4 @@
re ^(${TFTPBOOT_PATH}/) ${TFTPBOOT_PATH}/\2
re ^${TFTPBOOT_PATH}/ ${TFTPBOOT_PATH}/
re ^(^/) ${TFTPBOOT_PATH}/\1
re ^([^/]) ${TFTPBOOT_PATH}/\1