22.36. packer-builder - Packer Builder Images

The following documentation is for Packer Builder Images (packer-builder) content package at version v4.12.0-alpha00.78+gc037aaa40eb3ad853690ce178f9ab8a5bae4c436.

22.36.1. Object Specific Documentation params

The content package provides the following params. 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 gitlab repo status](https://gitlab.com/rackn/provision-content/tree/v4/packer-builder/packer/STATUS.md) 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 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. 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 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 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/ 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):

```json {

“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. 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. stages

The content package provides the following stages. 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. 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. tasks

The content package provides the following tasks. 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. 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. packer-builder-hypervisor-setup

Installs the hypervisor for the packer builder image builds. packer-builder-intall-tools

Installs Packer, Packer Plugins, Vagrant, and other required tools on the target platform in preparation of the image builds. 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. workflows

The content package provides the following workflows. 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. 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. 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. 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.