21.34. packer-builder - Packer Builder Images

The following documentation is for Packer Builder Images (packer-builder) content package at version v4.8.0-alpha00.25+g8e224a5bec085c80968ec27e0332c339a65d0659.

21.34.1. Packer Builder

21.34.2. Object Specific Documentation

21.34.2.1. tasks

The content package provides the following tasks.

21.34.2.1.1. packer-builder-build-image

Starts the Packer Builder image build for a given build target. The Build target is specified by the packer-builder/build-image param setting.

21.34.2.1.2. packer-builder-git-packer

Performs a git checkout of the packer-builder/packer/ directory in the digitalrebar/provision-content repo.

The git repo directory will be checked out in the packer-builder/packer/ directory on the Machine this is run from.

21.34.2.1.3. packer-builder-hypervisor-setup

Installs the hypervisor for the packer builder image builds.

21.34.2.1.4. packer-builder-intall-tools

Installs Packer, Packer Plugins, Vagrant, and other required tools on the target platform in preparation of the image builds.

21.34.2.1.5. packer-builder-upload-to-drp

The param packer-builder/upload-image gets set with a list of built images that are finalized and ready for Image Deploy via DRP.

Uploads it to the Digital Rebar Files service location. If an image exists at the specified path, it’ll be overwritten.

21.34.2.2. workflows

The content package provides the following workflows.

21.34.2.2.1. packer-setup-and-build

This workflow prepares a CentOS or Ubuntu target system with tooling for Packer and installs a Hypervisor to perform image builds. An image build will be started based on the packer-builder/build-image Param value.

21.34.2.2.2. packer-setup-only

This workflow prepares a CentOS or Ubuntu target system with tooling for Packer and installs a Hypervisor to perform image builds.

No image build process is started.

21.34.2.2.3. packer-upload-only

This workflow only uploads the image that was built, and has been recorded in the packer-builder/upload-image param, to the DRP Files space.

21.34.2.2.4. packer-build-image-only

This workflow only attempts to perform an image build on the target machine, according to the packer-builder/build-image Param define build target.

Warning

It is assumed the remote Machine that is running this content has already been prepared, hypervisor installed, and the Packer Builder packer JSON config and components cloned in place already.

21.34.2.3. params

The content package provides the following params.

21.34.2.3.1. packer-builder/upload-image

The packer builder system will add this param to the Machine when it completes the image build process. The image will be uploaded to DRP in the Files space under:

  • <DRP_ENDPOINT>:8091/files/images/builder/

21.34.2.3.2. packer-builder/var-file

If a value is set for this Param, the Packer build will use this file as the variables override. If this is not set, then the default of variables.json in the packer directory will be used.

Warning

To utilize a custom variables set of values, the operator must first render or make available the JSON variables file on the system that the content will run on.

Example value for this Param: /tmp/variables.json

The file specified must be in valid JSON format. You may specify only the specifc build variables that you wish to override, otherwise, the embedded Variable references in each target build will take precedence.

An example of valid JSON format for setting variables is below (this is an example of the files content that should be rendered for use on the system):

{
  "disk_size": "20480",
  "output_directory": "output",
  "complete_directory": "complete",
  "winrm_username": "vagrant",
  "winrm_password": "vagrant",
  "ssh_username": "rocketskates",
  "ssh_password": "RocketSkates"
}

Note

The above example may not be the most up to date set of variables that are available to override in the JSON files. Please see the file named variables.json in the packer directory for more recent options.

Most notably - the output_directory and complete_directory should be located on a filesystem with sufficient space for the builds. Windows builds can take MASSIVE GOBS of disk space - basically plan for a minimum of 4x the disk_size variable setting to be completely safe.

21.34.2.3.3. packer-builder/work-dir

This param specifies the base working directory for all of the Image Build activitiy to be hosted from.

The default location is /builder.

Warning

This directory must be on a filesystem with sufficient space for the builds that need to be performed.

21.34.2.3.4. packer-builder/build-image

Defines the image build to run on the packer builder system.

There is no default value specified, if this Param is not set to a value, no image builds will be completed.

Warning

Read the github repo status file for details on builds that have been verified working. This is a changing list as the packer build images are tested.

The list of available builds in the Makefile are as follows:

  • linux-ubuntu-1804-virtualbox
  • linux-ubuntu-1804-libvirt
  • windows-10-libvirt
  • windows-10-virtualbox
  • windows-10-vsphere
  • windows-10-1903-libvirt
  • windows-10-1903-virtualbox
  • windows-10-1909-libvirt
  • windows-10-1909-uefi-libvirt
  • windows-10-1909-virtualbox
  • windows-2012-r2-virtualbox
  • windows-2012-r2-libvirt
  • windows-2016-libvirt
  • windows-2016-virtualbox
  • windows-2016-vsphere
  • windows-2019-libvirt
  • windows-2019-uefi-libvirt
  • windows-2019-uefi-virtualbox
  • windows-2019-virtualbox
  • windows-2019-vsphere

21.34.2.3.5. packer-builder/git-branch

Specify the git branch to checkout for the Packer contents - useful for debugging when building / testing content not fully checked out in the git repo.

Default value is v4 for the branch.

21.34.2.3.6. packer-builder/hypervisor

Defines the supported hypervisor to deploy for the Packer images to be built by.

The default value is kvm.

The currently tested and automated hyperviser deployment is KVM on either CentOS or Ubuntu platforms. Other close linux distro variantes may also work, but have not been tested.

The Packer JSON builds support KVM (libvirt), VirtualBox, and vSphere. Building images can be done utilizing this content pack for other hypervisor versions if the operator sets up the hypervisor by hand first.

The list of Packer JSON supported hypervisor build environments is below. Note that this list has not been extensively tested, and debugging of various hypervisor configuraions may be required if you use anything except kvm type.

  • kvm
  • virtualbox
  • vsphere

21.34.2.3.7. packer-builder/make-override

This Param, if it has a value set, will allow the operator to pass a custom make command invocation in to the packer builder system. This allows for easier execution/run of builds with unique options or values set to affect the Makefile build tartet runs.

An example valid make command is as follows:

  • TMPDIR=$(pwd)/tmp PACKER_OPTIONS="-var-file=variables.json" PACKER_LOG=1 make build-windows-10-1909-libvirt

21.34.2.4. stages

The content package provides the following stages.

21.34.2.4.1. packer-builder-prep

This Stage installs prerequisite tools and installs the Hypervisor as defined by the packer-builder/hypervisor Param value. By default this will be the KVM/Libvirt/Qemu build solution.

21.34.2.4.2. packer-builder-upload-to-drp

This stage uploads an image that is specified in the Param named packer-builder/upload-image, to the DRP endpoint. This is typically used after the packer-builder-build-image Stage to push the image to DPR for deployment by the Image Deploy plugin.