HardenedBSD/release/tools/openstack.conf
Colin Percival 0b1c5628c7 release: Rework vm_extra_pre_umount
The vm_extra_pre_umount function in vmimage.subr served two purposes:
It removed /etc/resolv.conf and /qemu (if cross-building), and it
provided a function for cloudware to override in order to make cloud
specific changes to the filesystem before constructing a disk image.

This resulted in a number of bugs:
1. When cross-building, the emulator binary was left as /qemu in the
Azure, GCE, Openstack and Vagrant images.
2. The build host's resolv.conf was left as /etc/resolv.conf in the
basic-ci and basic-cloudinit images.
3. When building GCE images, a Google-specific resolv.conf file was
constructed, and then deleted before the disk image was created.

Move the bits needed for running code inside a VM staging directory
from vm_install_base into a new vm_emulation_setup routine, and move
the corresponding cleanup bits from vm_extra_pre_umount to a new
vm_emulation_cleanup routine.

Remove the /qemu and /etc/resolv.conf cleanups from the cloudware
configuration files (where they exist) since we will now be running
vm_emulation_cleanup to remove those even when vm_extra_pre_umount
has been overridden.

Override vm_emulation_cleanup in gce.conf since in that one case (and
*only* that one case) we don't want to clean up resolv.conf (since it
was constructed for the VM image rather than copied from the host).

releng/14.1 candidate.

MFC after:	1 week
Sponsored by:	https://www.patreon.com/cperciva
2024-05-06 13:40:47 -07:00

53 lines
1.8 KiB
Bash

#!/bin/sh
#
#
# Set to a list of packages to install.
export VM_EXTRA_PACKAGES="net/cloud-init devel/py-pbr devel/py-iso8601 \
net/py-eventlet net/py-netaddr comms/py-serial devel/py-six \
devel/py-babel net/py-oauth net/py-netifaces"
# Set to a list of third-party software to enable in rc.conf(5).
export VM_RC_LIST="cloudinit"
export NOSWAP=YES
vm_extra_pre_umount() {
#Enable sshd by default
echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
# Disable DNS lookups by default to make SSH connect quickly
echo 'UseDNS no' >> ${DESTDIR}/etc/ssh/sshd_config
# Allow root to ssh using keys
echo 'PermitRootLogin without-password' >> ${DESTDIR}/etc/ssh/sshd_config
# Disable sendmail
echo 'sendmail_enable="NO"' >> ${DESTDIR}/etc/rc.conf
echo 'sendmail_submit_enable="NO"' >> ${DESTDIR}/etc/rc.conf
echo 'sendmail_outbound_enable="NO"' >> ${DESTDIR}/etc/rc.conf
echo 'sendmail_msp_queue_enable="NO"' >> ${DESTDIR}/etc/rc.conf
# Enable DHCP for the OpenStack instance
echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
# Openstack wants sudo(8) usable by default without a password.
echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> \
${DESTDIR}/usr/local/etc/sudoers.d/cloud-init
# The console is not interactive, so we might as well boot quickly.
echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf
echo 'boot_multicons="YES"' >> ${DESTDIR}/boot/loader.conf
echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
# Reboot quickly, Don't wait at the panic screen
echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf
echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf
echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf
touch ${DESTDIR}/firstboot
return 0
}