summaryrefslogtreecommitdiffstats
path: root/release/tools
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2015-07-02 16:17:05 +0000
committergjb <gjb@FreeBSD.org>2015-07-02 16:17:05 +0000
commit6c9b1bee2d67c05c5bd0066aa73af98a34964afb (patch)
treee43943fc9c18cb293b374bbfc21ddcaf374f6965 /release/tools
parent5daf218e81467da2c3e933c0414219081e74b9d7 (diff)
downloadFreeBSD-src-6c9b1bee2d67c05c5bd0066aa73af98a34964afb.zip
FreeBSD-src-6c9b1bee2d67c05c5bd0066aa73af98a34964afb.tar.gz
MFC r284893, r284895-r284897, r284942, r284968, r284996, r285005:
r284893 (brd): Add initial support for building Vagrant images for VMWare. Next steps will be adding Virtualbox support and uploading to Hashicorp Atlas for others to consume. r284895: Add default VAGRANT_IMG variable. r284896: Remove _ACCOUNT and add _USERNAME, _NAME, _VERSION for the VAGRANT_${VAR} variables extracted from VAGRANT_UPLOAD_CONF. Set ATLAS_${VAR} to VAGRANT_${VAR} if VAGRANT_UPLOAD_CONF is set. There is intent to intentionally have separate variants of configuration entries, but the defaults do not yet have any reason to be different. r284897: Instead of hard-coding the PROVIDERS for upload, add the VAGRANT_PROVIDERS variable. Right now, it defaults to only vmware_desktop, virtualbox support is to follow at some point. While here, fix the hashicorp URL: s/vagrant/atlas/, which was result of a sed(1) replace (and my fault). r284942 (brd): Add Support for uploading Vagrant images to Hashicorp Atlas. r284968: Default the VAGRANT_VERSION to ${REVISION}-${BRANCH} if not set, which expands to '11.0-CURRENT', for example. If the branch is -CURRENT, -STABLE, or -PRERELEASE, suffix the VAGRANT_VERSION with the snapshot date. r284996: Fix the gcloud port/package name. r285005: Remove the HH-MM suffix from the build date suffix. It was useful when working out several kinks when testing automated image uploading when retrying was necessary, but now it is making things much too messy. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'release/tools')
-rw-r--r--release/tools/vagrant.conf81
1 files changed, 81 insertions, 0 deletions
diff --git a/release/tools/vagrant.conf b/release/tools/vagrant.conf
new file mode 100644
index 0000000..7e629ca
--- /dev/null
+++ b/release/tools/vagrant.conf
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# Packages to install into the image we're creating. This is a deliberately
+# minimalist set, providing only the packages necessary to bootstrap.
+export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs"
+
+vm_extra_pre_umount() {
+ # The firstboot_pkgs rc.d script will download the repository
+ # catalogue and install or update pkg when the instance first
+ # launches, so these files would just be replaced anyway; removing
+ # them from the image allows it to boot faster.
+ env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} delete -f -y pkg
+ rm ${DESTDIR}/var/db/pkg/repo-*.sqlite
+
+ # The size of the EC2 root disk can be configured at instance launch
+ # time; expand our filesystem to fill the disk.
+ echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+
+ # Vagrant instances use DHCP to get their network configuration.
+ echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+
+ # 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
+
+ # 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
+
+ # sudo is required
+ echo 'firstboot_pkgs_list="sudo rsync"' >> ${DESTDIR}/etc/rc.conf
+
+ # Create the vagrant user with a password of vagrant
+ /usr/sbin/pw -R ${DESTDIR} \
+ groupadd vagrant -g 1001
+ chroot ${DESTDIR} mkdir -p /home/vagrant
+ /usr/sbin/pw -R ${DESTDIR} \
+ useradd vagrant \
+ -m -M 0755 -w yes -n vagrant -u 1001 -g 1001 -G 0 \
+ -c 'Vagrant User' -d '/home/vagrant' -s '/bin/csh'
+
+ # Change root's password to vagrant
+ echo 'vagrant' | /usr/sbin/pw -R ${DESTDIR} \
+ usermod root -h 0
+
+ # Configure sudo to allow the vagrant user
+ echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> ${DESTDIR}/usr/local/etc/sudoers
+
+ # Configure the vagrant ssh key
+ mkdir ${DESTDIR}/home/vagrant/.ssh
+ chmod 700 ${DESTDIR}/home/vagrant/.ssh
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > ${DESTDIR}/home/vagrant/.ssh/authorized_keys
+ chown -R 1001 ${DESTDIR}/home/vagrant/.ssh
+ chmod 600 ${DESTDIR}/home/vagrant/.ssh/authorized_keys
+
+ # 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
+
+ # The console is not interactive, so we might as well boot quickly.
+ echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
+
+ # The first time the VM boots, the installed "first boot" scripts
+ # should be allowed to run:
+ # * growfs (expand the filesystem to fill the provided disk)
+ # * firstboot_freebsd_update (install critical updates)
+ # * firstboot_pkgs (install packages)
+ touch ${DESTDIR}/firstboot
+
+ return 0
+}
OpenPOWER on IntegriCloud