beaker-hostgenerator is a command line utility designed to generate beaker
host config files using a compact command line SUT specification.
Table of Contents
- Beaker Host Generator
- Hypervisors
- Usage
- Simple two-host layout
- Single host with Arbitrary Roles
- Two hosts with multiple hypervisors and arbitrary host settings
- Two hosts with arbitrary host settings with arbitrary lists
- Arbitrary nested hashes and arrays
- Arbitrary global configuration settings
- Custom hypervisor
- URL-encoded input
- OpenBSD hosts
- Testing
- Support
- License
Any hypervisor may be specified and generated, but if it's not a built-in hypervisor you will have to provide the entire hypervisor configuration as input. See the Custom hypervisor example for more information.
It currently provides built-in configuration for Puppets' internal vmpooler hypervisor, always-be-scheduling hypervisor, Vagrant with Virtualbox and Libvirt backend, Hetzner cloud, static (non-provisioned) nodes, and is designed in a way that makes it possible to easily add support for additional hypervisors (any hypervisor type supported by beaker).
To see the list of built-in hypervisors you can run:
$ beaker-hostgenerator --list
With --hypervisor=docker each host gets an image. Linux hosts with a
64, AARCH64 or POWER architecture also get a
docker_platform setting that matches the architecture in the host
specification: linux/amd64 for 64, linux/arm64 for AARCH64 and
linux/ppc64le for POWER. beaker-docker versions that
support it pass it to Docker when building or pulling the image, so the image is
for the requested architecture even if it differs from that of the Docker host.
Older versions ignore it.
To test another architecture, change the architecture in the host
specification: ubuntu2204-AARCH64 generates an ARM host, with an ARM image and
Beaker platform to match. Overriding docker_platform alone does not do that.
Most 64 hosts use an amd64/ image repository, which only contains amd64
images, and their Beaker platform stays amd64, so
ubuntu2204-64{docker_platform=linux/arm64} would produce a host whose settings
contradict each other.
docker_platform is an ordinary host setting, so it can be overridden to refine
the generated value for a single host while the architecture stays the same,
e.g. ubuntu2204-AARCH64{docker_platform=linux/arm64/v8}.
The generated config includes a vendor catalog URL for Oracle Linux 7–10 and
AlmaLinux 8–10 on x86_64. Use Vagrant 2.4 or newer for AlmaLinux 9 and 10
with VirtualBox, on ARM64 and x86_64 alike. Their ARM64 libvirt defaults use
cloud-image/ boxes from HCP Vagrant, which shuts down on 31 December 2026.
To use a different box, supply {box=...} and, if needed, box_url in the same host settings.
If you already have an AlmaLinux box installed from HCP Vagrant, follow the vendor's migration steps to refresh its cached catalog URL. AlmaLinux catalog migration guide
Below are some example usages of beaker-hostgenerator.
$ beaker-hostgenerator centos9-64mdca-64a
Will generate
---
HOSTS:
centos9-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-9-x86_64
template: centos-9-x86_64
roles:
- agent
- master
- database
- dashboard
centos9-64-2:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-9-x86_64
template: centos-9-x86_64
roles:
- agent
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/Start each role name with one or more lowercase letters. From the first digit or
underscore onward, use only a-z, 0-9, and _.
Separate names with commas and end the list with a period, even when no static
roles follow (for example, centos9-64role2.).
$ beaker-hostgenerator centos9-64compile_master,role2.ma
Will generate
---
HOSTS:
centos9-64-1:
platform: el-9-x86_64
hypervisor: vmpooler
template: centos-9-x86_64
roles:
- agent
- master
- compile_master
- role2
main:
dns_alt_names: puppet
environmentpath: "/etc/puppetlabs/puppet/environments"
CONFIG:
pooling_api: https://vmpooler-prod.k8s.infracore.puppet.net/$ beaker-hostgenerator centos9-64m{hypervisor=none\,hostname=static-master}-redhat7-64a{somekey=some-value}
Will generate
---
HOSTS:
static-master:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
platform: el-9-x86_64
hypervisor: none
roles:
- agent
- master
redhat7-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-7-x86_64
template: redhat-7-x86_64
somekey: some-value
roles:
- agent
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/$ beaker-hostgenerator centos9-64m{disks=\[16\]}-redhat7-64a{disks=\[8\,16\]}
Will generate
---
HOSTS:
centos9-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
platform: el-9-x86_64
hypervisor: vmpooler
disks:
- 16
roles:
- agent
- master
redhat7-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-7-x86_64
template: redhat-7-x86_64
disks:
- 8
- 16
roles:
- agent
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/$ beaker-hostgenerator --global-config {host_tags={lifetime=4h}\,list=[{listkey=listvalue}]\} redhat7-64m{hostlist=\[string\,{key=value}\,1234\]}
Will generate
---
HOSTS:
redhat7-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-7-x86_64
template: redhat-7-x86_64
hostlist:
- string
- key: value
- 1234
roles:
- agent
- master
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/
host_tags:
lifetime: 4h
list:
- listkey: listvalue$ beaker-hostgenerator --global-config {preserve_hosts=onfail\,log_level=debug\,server.ip=12.345.6789} redhat7-64m
Will generate
---
HOSTS:
redhat7-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-7-x86_64
template: redhat-7-x86_64
roles:
- agent
- master
CONFIG:
nfs_server: none
consoleport: 443
preserve_hosts: onfail
log_level: debug
server.ip: 12.345.6789
pooling_api: http://vmpooler.delivery.puppetlabs.net/The following example shows one way of generating a custom hypervisor that includes both per-host configuration and global configuration.
The term "custom" in this case signifies that it's not a built-in hypervisor
(like vmpooler), which means we'll have to provide all the configuration
ourselves as there isn't any built-in configuration for our hypervisor.
$ beaker-hostgenerator --hypervisor=custom --global={custom_api=http://api.custom.net} centos9-64
Will generate
---
HOSTS:
centos9-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
platform: el-9-x86_64
hypervisor: custom
roles:
- agent
CONFIG:
nfs_server: none
consoleport: 443
custom_api: http://api.custom.netIt may be necessary to URL-encode the input in order for it to properly be used in certain contexts, such as Jenkins.
In most cases it will only be necessary to escape the characters that support arbitrary settings, which means the following characters:
{is%7B,is%2C}is%7Dis%20[is%5B]is%5D
For a full URL encoding reference see: http://www.w3schools.com/tags/ref_urlencode.asp
$ beaker-hostgenerator centos9-64mcd-aix53-POWERfa%7Bhypervisor=aix%2Cvmhostname=pe-aix-53-acceptance.delivery.puppetlabs.net%7D
Is equivalent to
$ beaker-hostgenerator centos9-64mcd-aix53-POWERfa{hypervisor=aix,vmhostname=pe-aix-53-acceptance.delivery.puppetlabs.net}
And will generate
---
HOSTS:
centos9-64-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-9-x86_64
template: centos-9-x86_64
roles:
- agent
- master
- dashboard
- database
aix53-POWER-1:
pe_dir:
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
platform: aix-5.3-power
hypervisor: aix
vmhostname: pe-aix-53-acceptance.delivery.puppetlabs.net
roles:
- agent
- frictionless
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/OpenBSD 7.9 and 8.0 on amd64 use the layout keys openbsd79-64 and
openbsd80-64. Use none for an existing machine, for example:
beaker-hostgenerator --hypervisor none 'openbsd80-64a{ip=192.0.2.10}'For vagrant or vagrant_libvirt, specify your own provider-compatible box
with {box=...} and optionally {box=...,box_url=...} for a custom download
location. VMPooler (the CLI default) and ABS require a template from your
service. Supply it with {template=...}. Docker and the container hypervisor
aliases cannot run OpenBSD guests.
Beaker Host Generator currently uses both rspec and minitest tests. To run both at the same time, run:
bundle exec rake testBeaker Host Generator makes extensive use of test fixtures to validate its behavior under specific conditions. An example of such a test fixture is as follows:
---
arguments_string: "--pe_dir /opt/hello centos9-64mdc"
environment_variables: {}
expected_hash:
HOSTS:
centos9-64-1:
pe_dir: "/opt/hello"
pe_ver:
pe_upgrade_dir:
pe_upgrade_ver:
hypervisor: vmpooler
platform: el-9-x86_64
template: centos-9-x86_64
roles:
- agent
- master
- database
- dashboard
CONFIG:
nfs_server: none
consoleport: 443
pooling_api: http://vmpooler.delivery.puppetlabs.net/
expected_exception:These test fixtures are yaml files searched for in the directory
test/fixtures. The data structure expected in these files is a hash with four
keys:
arguments_string: The command line arguments that should be passed tobeaker-hostgeneratorenvironment_variables: The environment variables that should be set during thebeaker-hostgeneratorcall.expected_hash: A hash that should match the output ofbeaker-hostgeneratorwhen it is run witharguments_stringexpected_exception: If thearguments_stringpassed tobeaker-hostgeneratoris expected to lead to an exceptional state, this is the name of the exception that the fixture test will attempt to match.
It is possible to generate test fixtures using the current state of the
beaker-hostgenerator library. To do this, call the generate:fixtures Rake
task.
However, this is not something that should need to be done very often. If you
are running tests and find that some fixtures no longer work, you have most
likely made a change that incompatibly changes the behavior of
beaker-hostgenerator for other users. Use the test fixtures as a guide to
figure out what you did wrong and figure out how to achieve your goal without
potentially breaking beaker-hostgenerator for other users.
There are a few circumstances when you should expect to run the
generate:fixtures task:
- When you modify the
FixtureGeneratorto generate new fixtures. - When you need to fix a bug (generated hosts are not usable without your change, for example).
- When preparing for a major version bump of Beaker Host Generator.
Support offered by Puppet may not always be timely since it is maintained by a tooling support team that is primarily focused on improving tools, infrastructure, and automation for our Enterprise products.
That being said, we will happily accept and review PRs from community members
interested in extending and using beaker-hostgenerator for their own purposes.
See the contributing doc for more information about how to
contribute.
If you have questions or comments, please contact the Beaker team at the
#puppet-dev IRC channel on chat.freenode.org
This plugin was originally authored by Puppet Inc. The maintainer preferred that Vox Pupuli take ownership of the module for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute at https://github.com/voxpupuli/beaker-hostgenerator
Previously: https://github.com/puppetlabs/beaker-hostgenerator
To make a new release:
- Switch to a new git branch
- Update
lib/beaker-hostgenerator/version.rbto the new version - export
CHANGELOG_GITHUB_TOKENwith a GitHub access token - run
bundle exec rake changelog - Review the CHANGELOG.md
- Create a PR
- Get it reviewed and merged
- Create a signed git tag with the same version number and push it
- GitHub actions will do the release
beaker-hostgenerator is distributed under the
Apache License, Version 2.0. See the LICENSE file for more details.