bento
Packer templates for building minimal Vagrant baseboxes for multiple platforms
Top Related Projects
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
Quick Overview
Bento is a project by Chef that provides a set of base box templates for Vagrant and other virtualization platforms. It aims to create consistent, minimal base boxes for various operating systems, making it easier for developers to set up and manage development environments across different platforms.
Pros
- Offers a wide range of pre-built, minimal base boxes for various operating systems
- Regularly updated to include the latest OS versions and security patches
- Provides consistent environments across different development machines
- Supports multiple virtualization platforms, including VirtualBox, VMware, and Parallels
Cons
- Limited customization options for pre-built boxes
- Requires familiarity with Vagrant or other virtualization tools
- May not include all necessary software for specific development needs
- Large download sizes for some base boxes
Getting Started
To use Bento boxes with Vagrant:
- Install Vagrant and a supported virtualization platform (e.g., VirtualBox)
- Choose a Bento box from the available list
- Create a
Vagrantfile
in your project directory:
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
end
- Run
vagrant up
to start the virtual machine
For building custom Bento boxes:
- Clone the Bento repository:
git clone https://github.com/chef/bento.git
cd bento
- Install required tools (Packer, VirtualBox, etc.)
- Build a box using Packer:
packer build -only=virtualbox-iso ubuntu/ubuntu-20.04-amd64.json
- Add the built box to Vagrant:
vagrant box add builds/ubuntu-20.04.virtualbox.box --name custom/ubuntu-20.04
Competitor Comparisons
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
Pros of Packer
- More versatile, supporting a wider range of platforms and cloud providers
- Actively maintained with frequent updates and a larger community
- Offers more advanced features like post-processors and provisioners
Cons of Packer
- Steeper learning curve, especially for beginners
- Requires more configuration and setup compared to Bento's simpler approach
- May be overkill for basic VM image creation tasks
Code Comparison
Bento (Vagrant):
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
config.vm.provision "shell", inline: "echo Hello, World!"
end
Packer:
{
"builders": [{
"type": "virtualbox-iso",
"guest_os_type": "Ubuntu_64",
"iso_url": "http://releases.ubuntu.com/20.04/ubuntu-20.04-desktop-amd64.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant"
}],
"provisioners": [{
"type": "shell",
"inline": ["echo Hello, World!"]
}]
}
The code comparison shows that Packer requires more detailed configuration but offers greater flexibility in specifying build parameters and provisioning steps. Bento, being Vagrant-focused, provides a simpler configuration for quickly setting up development environments.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Bento
Bento is a project that encapsulates Packer templates for building Vagrant base boxes. A subset of templates are built and published to the bento org on Vagrant Cloud. These published boxes serve as the default boxes for kitchen-vagrant.
*NOTE:
- Vagrant 2.4.0+ is required for new cpu architecture support
- For
bento test
command to work test-kitchen and kitchen-vagrant gems must be installed - Virutalbox 6.x requires disabling nat config that allows vbox 7.x guests to connect to the host. To use comment out lines #161 and #162 in bento/packer_templates/pkr-variables.pkr.hcl or add variable
vboxmanage = []
to os_pkrvars files. - When running packer build command the output directory is relative to the working directory the command is currently running in. Suggest running packer build commands from bento root directory for build working files to be placed in bento/builds/(build_name) directory by default. If the output_directory variable isn't overwritten a directory called builds/(build_name) will be created in the current working directory that you are running the command from
Using Public Boxes
Adding a bento box to Vagrant
vagrant box add bento/ubuntu-18.04
Using a bento box in a Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
end
Installing Bento
- install ruby environment
- clone repo
- cd <path/to>/bento
- gem build bento.gemspec
- gem install bento-*.gem
Building Boxes
Requirements
- Packer >= 1.7.0
- Vagrant >= 2.4.0
- At least one of the following virtualization providers:
- VirtualBox*2
- VMware Fusion*2
- VMware Workstation*2
- Parallels Desktop Pro also requires Parallels Virtualization SDK for versions < 19.x
- qemu *1 *2
- Hyper-V *1 *2
*1 NOTE: support for these providers is considered experimental and corresponding Vagrant Cloud images may or may not exist.
*2 NOTE: AARCH64 or ARM64 support is a work in progress only guaranteed through parallels and vmware provider.
Using bento
executable
build
To build a Debian vagrant box using the bento tool with the template available in the os_pkrvars
dir, we can use the following command:
bento build --cpus 2 os_pkrvars/debian/debian-12-x86_64.pkrvars.hcl
Other available options:
- cpus - Specify the number of CPUs needed in the new build
- mem - Specify the memory
- config - Use a configuration file other than default builds.yml
- vars - Comma seperated list of variable names equal values (ex: boot_wait="2s",ssh_timeout="5s")
- var_files - Comma seperated list of pkrvar.hcl files to include in the builds (ex: /path/to/var_file.pkrvars.hcl,/path/to/next/var_file2.pkrvars.hcl)
- metadata_only - Only generate the metadata json file
- mirror - The template will have a default mirror link, if you wish to use an alternative one, you can utilise this configuration
- dry-run - This will not create any build, but will create a metadata file for reference
- only - Only build some Packer builds (Default: parallels-iso.vm,virtualbox-iso.vm,vmware-iso.vm
- except - Build all Packer builds except these (ex: parallels-iso.vm,virtualbox-iso.vm,vmware-iso.vm)
- debug - Print the debug logs
- gui - Packer will be building VirtualBox virtual machines by launching a GUI that shows the console of the machine being built. This option is false by default
- single - This can be used to disable the parallel builds
list
Used to list all builds available for the workstations cpu architecture. This list is also filtered by the build.yml file do_not_build: section. All entries are matched via regex to filter out build templates from the list.
This only shows what would be built with bento build
and no template is specified. If any template is specified even if it's in the build.yml to be filtered it'll override the filter.
bento list
test
If you have successfully built a vagrant box using the bento tool, you should have the vagrant box and a metadata file in the builds
folder. You can use these files to test the build with a test-kitchen configuration. Run the following command to test the build.
bento test
upload
To upload boxes in the builds directory to your vagrant cloud account update the build.yml file to specify your account name and which OSs are going to be public.
Make sure you have configured the vagrant cli and logged into your account for the upload command to work.
bento upload
When running bento upload
it'll read each <box_name>._metadata.json file and use the data provided to generate the vagrant cloud publish
command with the descriptions, version, provider, and checksums all coming from the <box_name>._metadata.json file.
Using packer
To build a Ubuntu 22.04 box for only the VirtualBox provider
cd <path/to>/bento
packer init -upgrade ./packer_templates
packer build -only=virtualbox-iso.vm -var-file=os_pkrvars/ubuntu/ubuntu-22.04-x86_64.pkrvars.hcl ./packer_templates
To build latest Debian 12 boxes for all possible providers (simultaneously)
cd <path/to>/bento
packer init -upgrade ./packer_templates
packer build -var-file=os_pkrvars/debian/debian-12-x86_64.pkrvars.hcl ./packer_templates
To build latest CentOS 7 boxes for all providers except VMware and Parallels
cd <path/to>/bento
packer init -upgrade ./packer_templates
packer build -except=parallels-iso.vm,vmware-iso.vm -var-file=os_pkrvars/centos/centos-7-x86_64.pkrvars.hcl ./packer_templates
To use an alternate url
cd <path/to>/bento
packer init -upgrade ./packer_templates
packer build -var 'iso_url=https://mirrors.rit.edu/fedora/fedora/linux/releases/39/Server/x86_64/iso/Fedora-Server-dvd-x86_64-39-1.5.iso' -var-file=os_pkrvars/fedora/fedora-39-x86_64.pkrvars.hcl ./packer_templates
If the build is successful, your box files will be in the builds
directory at the root of the repository.
KVM/qemu support for Windows
You must download the iso image with the Windows drivers for paravirtualized KVM/qemu hardware and place it in the builds/iso/ directory.
You can do this from the command line: mkdir -p builds/iso/; wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O builds/iso/virtio-win.iso
You can use the following sample command to build a KVM/qemu Windows box:
packer init -upgrade ./packer_templates
packer build --only=qemu.vm -var-file=os_pkrvars/windows/windows-2022-x86_64.pkrvars.hcl ./packer_templates
Proprietary Templates
Templates for operating systems only available via license or subscription are also available in the repository, these include but are not limited to: Red Hat Enterprise Linux, and SUSE Linux Enterprise. As the ISOs are not publicly available the URL values will need to be overridden as appropriate. We rely on the efforts of those with access to licensed versions of the operating systems to keep these up-to-date.
Networking/Firewalls
Most of the providers expect unrestricted access to networking in order to build as expected. We can't enumerate all possible firewall configurations but include some snippets below that might be useful to users.
Windows
$VS = "Standardswitch"
$IF_ALIAS = (Get-NetAdapter -Name "vEthernet ($VS)").ifAlias
New-NetFirewallRule -Displayname "Allow incomming from $VS" -Direction Inbound -InterfaceAlias $IF_ALIAS -Action Allow
Hyper-V Generation 2 VM's
Hyper-V Gen 2 VMs do not support floppy drives. If you previously provided resources using a floppy drive, you must add those files to your Gen 2 iso images, in particular:
autounattend.xml
: The Gen 2autounattend.xml
file supports EFI partitions. Update theautounattend.xml
with the correct Windows version for your systems and ensure that the partitions are correct for your situation. You also need to manage the driver disk that holds the hyper-v guest services drivers and adjust theautounattend.xml
file as appropriate.
Bugs and Issues
Please use GitHub issues to report bugs, features, or other problems.
Related projects
A huge thank you to these related projects from which we've taken inspiration and often used as a source for workarounds in complex world of base box building.
- https://github.com/boxcutter
- https://github.com/lavabit/robox
- https://github.com/mcandre/packer-templates
- https://github.com/timsutton/osx-vm-templates
- https://github.com/ferventcoder/vagrant-windows-puppet/tree/master/baseboxes
License & Authors
These basebox templates were converted from veewee definitions originally based on work done by Tim Dysinger to make "Don't Repeat Yourself" (DRY) modular baseboxes. Thanks Tim!
- Author: Chris McClimans (chris@hippiehacker.org)
- Author: Fletcher Nichol (fnichol@nichol.ca)
- Author: Joshua Timberman (joshua@chef.io)
- Author: Julian Dunn (jdunn@chef.io)
- Author: Ross Timson (ross@rosstimson.com)
- Author: Seth Chisamore (schisamo@chef.io)
- Author: Stephen Delano (stephen@chef.io)
- Author: Tim Dysinger (tim@dysinger.net)
- Author: Tim Smith (tsmith@chef.io)
- Author: Tom Duffield (tom@chef.io)
- Author: Corey Hemminger (corey.hemminger@progress.com)
Copyright 2012-2024, Progress Software, Inc. (<legal@chef.io>)
Copyright 2011-2012, Tim Dysinger (<tim@dysinger.net>)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Top Related Projects
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot