Advanced: Packer & Bento Integration

Laravel Settler does not work in isolation. It is designed to be a component within a larger build process orchestrated by Packer and based on the Chef Bento project. Understanding this relationship is key to advanced customization.

The Role of Chef Bento

Chef Bento provides a community-standard set of Packer templates for building base virtual machine images for various operating systems and providers. Settler leverages Bento for:

  • Packer Templates: The core .pkr.hcl files that define the build process, including builders (for VirtualBox, VMware, etc.) and basic provisioners.
  • Automated OS Installation: Scripts and configuration files that automate the installation of a clean Ubuntu server.
  • Base Provisioning: Initial setup scripts for creating the vagrant user, installing guest additions, and performing initial system cleanup.

Settler's role is to override and extend the final provisioning step of the Bento process.

The bin/link-to-bento.sh and bin/link-to-bento.ps1 scripts are the glue that connects Settler to Bento. When executed, they perform several key modifications to the cloned Bento repository.

1. Script Symlinking

The script creates symbolic links to scripts/amd64.sh and scripts/arm.sh inside the Bento scripts directory. This makes the Settler provisioning scripts accessible to the Packer build process running from the Bento directory.

# from link-to-bento.sh
/bin/ln -f scripts/amd64.sh ../bento/packer_templates/scripts/ubuntu/homestead_amd64.sh
/bin/ln -f scripts/arm.sh ../bento/packer_templates/scripts/ubuntu/homestead_arm.sh

2. Overriding the Provisioner

By default, Bento's Packer templates run a final cleanup.sh script. The link script uses sed to edit the main Packer build file (pkr-builder.pkr.hcl) and replace this cleanup script with a call to the newly linked Homestead script.

# from link-to-bento.sh
sed -i 's/${var.os_name}\/cleanup_${var.os_name}.sh/ubuntu\/homestead_amd64.sh/' ../bento/packer_templates/pkr-builder.pkr.hcl

This is the critical step that injects all of Homestead's software installation and configuration logic into the build.

3. Modifying Packer Variables

The script also modifies pkr-variables.pkr.hcl to increase the default virtual machine disk size from 64GB to 512GB to accommodate the extensive software stack.

# from link-to-bento.sh
sed -i 's/65536/524288/' ../bento/packer_templates/pkr-variables.pkr.hcl

The preseed.cfg Files

Located in the http/ directory, the preseed.cfg files are used to automate the Ubuntu installation process (a technique known as "preseeding"). Packer configures the virtual machine to boot and load this file over a temporary HTTP server.

This file provides answers to all the prompts that would normally appear during an interactive Ubuntu Server installation, including:

  • Language and keyboard layout.
  • Network configuration.
  • Partitioning scheme (creating a homestead-vg LVM group).
  • Default user creation (creating the vagrant user with the password vagrant).
  • Initial package selection (installing openssh-server, ntp, etc.).

A separate preseed-hyperv.cfg is provided with minor adjustments for builds targeting Microsoft Hyper-V.