Customize your Image YAML or Manifest File
DKP provides default YAML files for each Infrastructure Provider and their supported Operating Systems. Those default YAML files can easily be modified by replacing values. The simplest way is to open the default YAML for your OS in an editor and change a line. For example, in the following YAML, you can name a specific image rather than accepting the default source_ami: ""
AWS Example: # Example images/ami/rhel-86.yaml
---
# Example images/ami/rhel-86.yaml
download_images: true
packer:
ami_filter_name: "RHEL-8.6.0_HVM-*"
ami_filter_owners: "309956199498"
distribution: "RHEL"
distribution_version: "8.6"
source_ami: ""
ssh_username: "ec2-user"
root_device_name: "/dev/sda1"
volume_size: "15"
build_name: "rhel-8.6"
packer_builder_type: "amazon"
python_path: ""
Once the YAML for the image is edited, you then create your image using the customized YAML by applying it in the command.
konvoy-image build aws images/ami/rhel-86.yaml
Generate a Packer File to Customize
Another method for customization is to edit your Packer template. When first running the Konvoy Image Builder(KIB) command to generate an image, it will automatically create the files needed for you to edit in a path called work folder.
First you will build an image and then you will edit the generated output to use in customizing another image. During the attempt to build the image, a packer.pkr.hcl
is generated under the path work/centos-7-xxxxxxx-yyyyy/packer.pkr.hcl
.
Run the image creation command:
CODEkonvoy-image build aws images/ami/ubuntu-2004.yaml
To avoid fully creating the image and reduce image charges, interrupt the command right after running it. This will still generate the needed files but avoid a full image creation charge.
A work file is generated (EX:
work/ubuntu-20-3486702485-iulvY
) which contains the files to be opened in an editor and the values added or changed:ansible_vars.yaml
packer_vars.json
packer.pkr.hcl
Open the
packer.pkr.hcl
file with an editor and change the values desired.Save and rename these changes as
manifest.pkr.kcl
so that it can be applied during image creation using the--packer-manifest
flag.
For a full list of KIB flags, run the command: konvoy-image build aws --help
Once the YAML for the image is edited, you then create another image using your customized YAML by applying it with the flag
--packer-manifest
. Provision the new image applying the recently edited and renamedmanifest.pkr.kcl
:AWS example:
CODEkonvoy-image build aws --packer-manifest manifest.pkr.hcl --overrides overrides/fips.yaml
Check final image for correct variables applied.