Anka
@veertuinc
This is a packer plugin for building macOS VM templates and tags using the Anka Virtualization CLI
- Community
Updated 2 months ago
- GitHub(opens in new tab)
Anka Build Cloud Registry Push
Type: veertu-anka-registry-push
The veertu-anka-registry-push Packer Post Processor is able to push your created Anka VM templates to the Anka Build Cloud Registry through the Anka Virtualization package.
This post-processor is part of the Veertu Anka plugin. To install this plugin using packer init, add the following Packer block to your hcl template:
packer {
required_plugins {
veertu-anka = {
version = "= 4.x.x"
source = "github.com/veertuinc/veertu-anka"
}
}
}
Configuration Reference
There are many configuration options available for the post-processor. They are segmented below into two categories: required and optional parameters.
Required Configuration
type(String) Must beveertu-anka-registry-push; no other types
Optional Configuration
cacert(String) Path to a CA Root certificate.cert(String) Path to your node certificate (if certificate authority is enabled).description(String) The description of the tag.insecure(Boolean) Skip TLS verification.key(String) Path to your node certificate key if the client/node certificate doesn't contain one.cacert,cert,insecure, andkeyare only for an Anka Registry. The build fails if you set them whenremoteis an OCI registry URL, becauseanka pushdoes not accept them.local(Boolean) Assign a tag to your local template and avoid pushing to the Registry.remote(String) The registry URL or name to target for registry operation (will use your default configuration if not set).(Anka 3.9.0+) To push to an OCI registry, set
remoteto an OCI registry URL: anoci://URL, or anhttp(s)://URL with/v2in its path (for exampleoci://registry.example.com/v2/veertu/). See Push to an OCI registry.thin(Boolean) (Anka 3.10.0+) Push only the layer that this build added, as a thin OCI tag (anka push --thin). Requiresremoteto be an OCI registry URL. Cannot be used withlocal. Defaults tofalse(a full OCI tag).remote_vm(String) The name of a registry template you want to push the local template onto.To push a new tag onto the registry template that you started from, without
remote_vm, setskip_clone = trueon theveertu-anka-vm-clonebuilder. The builder then provisionssource_vm_namein place, and the post-processor pushes it with its own name. Example: skip-clone-with-post-processing.pkr.hcltag(String) The name of the tag to push (will default as 'latest' if not set).force(Boolean) Whether or not to forcefully push, regardless of a tag already existingdelete_template_post_push(Boolean) Whentrue, after a successful remote registry push (localmust befalse) the post-processor runsanka delete --yeson the local VM template from the Anka builder (artifactname). It does not run forlocal = true(local tagging only). Defaults tofalse. Use this to avoid leaving duplicate local templates when reusing the samevm_nameacross builds. If deletion fails, the post-processor returns an error even though the push already succeeded.
Other
When using packer build -force, the post-processor will issue a revert API call to remove the existing tag before pushing the new.
Push to an OCI registry
When remote is an OCI registry URL, the post-processor runs anka push instead of anka registry push:
- It does not use the Anka Registry list and revert API. An OCI registry does not have it.
force = trueorpacker build -forceadds--force. An OCI push with the same tag name replaces the tag.- The repository is the last segment of the
remotepath after/v2/:oci://registry.example.com/v2/veertu/toolspushes toveertu/tools. If the path ends with/, the repository is the local VM name.remote_vmsets the repository name and overrides the path. - With
thin = true, the tag holds only the files that this build added. Pull it onto a VM that already has the base, for example with the clone builder'sthin_oci_pulls. - The Anka Build Cloud Controller pulls only from an Anka Registry. For a Controller template, push a full tag to the Anka Registry.
Registry credentials come from the host environment, for example ANKA_REGISTRY_AUTH_TOKEN. A remote name from anka registry add always uses anka registry push, even when that remote is an OCI registry.
post-processor "veertu-anka-registry-push" {
remote = "oci://registry.example.com/v2/veertu/"
tag = "xcode-26.1"
thin = true
}
Examples:
- clone-existing-with-thin-oci-tags.pkr.hcl (clone, then thin push)
- skip-clone-with-thin-oci-tags.pkr.hcl (
skip_clone, multiple thin pulls, then thin push)
Example
Here is an example that uses the file and shell provisioners.
Also see:
variable "source_vm_name" {
type = string
default = "anka-packer-base-macos"
}
variable "vm_name" {
type = string
default = "anka-packer-from-source"
}
source "veertu-anka-vm-clone" "clone" {
vm_name = "${var.vm_name}"
source_vm_name = "${var.source_vm_name}"
}
build {
sources = [
"source.veertu-anka-vm-clone.clone",
]
provisioner "file" {
destination = "/private/tmp/"
source = "./examples/ansible"
}
provisioner "shell" {
inline = [
"[[ ! -d /tmp/ansible ]] && exit 100",
"touch /tmp/ansible/test1"
]
}
post-processor "veertu-anka-registry-push" {
tag = "v2"
delete_template_post_push = true
}
}