Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

zarf_init

Initialise a cluster with a staged zarf init package.

Write it as colonel_byte.zarf.zarf_init. It runs zarf on the node the task is delegated to; nothing is installed on the cluster’s nodes.

Added in colonel_byte.zarf 0.0.1.

Runs zarf init against the cluster a kubeconfig names, and follows the init package’s deployment component by component.

The module is a compiled binary with zarf linked into it. It renders the zarf init command line from these parameters, executes zarf’s own init command in its own process, reads the component boundaries back out of zarf’s log stream, and reports one JSON result. It needs no zarf on the node.

This is a proof of ZEP-0072 (https://github.com/zarf-dev/proposals/pull/73), which proposes putting this dispatch inside the zarf binary itself.

Parameters

ParameterTypeRequiredFlagDescription
init_packagestrnoNoneThe init package to deploy, such as /srv/staging/zarf-init-amd64-v0.85.0.tar.zst. It is passed as the positional package source of zarf init, so the file needs no particular name and need not sit in any particular directory. An oci:// reference or an https:// URL may be given instead of a path, for a cluster whose packages come from a registry rather than from disk. A directory may also be given, which leaves zarf to find a package inside it the way it does when given no source at all: a file named after zarf’s own version. One of init_package or directory is required.
directorystrnoNoneThe working directory to run zarf in. A relative init_package, and a relative path inside a zarf config file named by zarf_config, are resolved against it. May be given together with init_package: the package says what to deploy, and this says where relative paths resolve from.
kubeconfigstrnoNoneThe kubeconfig of the cluster to initialise. Zarf has no --kubeconfig flag, so it is passed as KUBECONFIG in zarf’s environment.
zarf_configstrnoNoneA zarf config file, passed as ZARF_CONFIG. It is how a playbook keeps registry and git credentials out of the argument vector: zarf reads them from the file, so they never reach the process table.
wrapper_binarystrnoNoneThe module wrapper to run, resolved on the path when it holds no separator. The action plugin consumes this parameter; the wrapper never sees it.
status_filestrnoNoneWhere the wrapper writes live component progress. The action plugin creates a private temporary file and overrides this, so a task has no reason to set it. It is here for a run reproduced by hand.
parametersdictnoNoneFurther module parameters, merged into the ones given directly. It is how a role passes a caller-supplied set without templating a whole task’s arguments. A parameter given both directly and inside parameters is an error naming it. The action plugin consumes this key; the wrapper never sees it.
componentsstrno--componentsWhich init components to deploy, as a comma-separated list. It is also what lets the progress display report component 2/4 rather than component 2: the wrapper cannot otherwise know how many components the package holds.
storage_classstrno--storage-classThe storage class the init package’s persistent volumes are created with.
registry_urlstrno--registry-urlThe URL of an external registry to use instead of the one the init package deploys.
registry_modestrno--registry-modeHow zarf uses the registry.
registry_portintno--registry-portThe node port the internal registry is published on.
registry_secretstrno--registry-secretThe secret zarf derives registry credentials from.
registry_push_usernamestrno--registry-push-usernameThe username zarf pushes images with.
registry_push_passwordstrno--registry-push-passwordThe password zarf pushes images with.
registry_pull_usernamestrno--registry-pull-usernameThe username the cluster pulls images with.
registry_pull_passwordstrno--registry-pull-passwordThe password the cluster pulls images with.
git_urlstrno--git-urlThe URL of an external git server to use instead of the one the init package deploys.
git_push_usernamestrno--git-push-usernameThe username zarf pushes repositories with.
git_push_passwordstrno--git-push-passwordThe password zarf pushes repositories with.
git_pull_usernamestrno--git-pull-usernameThe username the cluster pulls repositories with.
git_pull_passwordstrno--git-pull-passwordThe password the cluster pulls repositories with.
injector_imagestrno--injector-imageThe image the zarf injector runs.
injector_portintno--injector-portThe port the zarf injector listens on.
agent_mutation_policystrno--agent-mutation-policyWhich resources the zarf agent mutates.
agent_tls_castrno--agent-tls-caThe certificate authority the zarf agent’s serving certificate is issued by.
agent_tls_certstrno--agent-tls-certThe zarf agent’s serving certificate.
agent_tls_keystrno--agent-tls-keyThe private key of the zarf agent’s serving certificate.
take_ownershipboolno--take-ownershipWhether zarf takes ownership of resources an earlier install created.
force_conflictsboolno--force-conflictsWhether zarf forces apply conflicts.
skip_values_schema_validationboolno--skip-values-schema-validationWhether zarf skips validating values files against their schema.
insecure_skip_tls_verifyboolno--insecure-skip-tls-verifyWhether zarf skips verifying TLS certificates it connects to.
plain_httpboolno--plain-httpWhether zarf talks to registries over plain HTTP.
retriesintno--retriesHow many times zarf retries a failed operation.
oci_concurrencyintno--oci-concurrencyHow many OCI operations zarf runs at once.
architecturestrno--architectureThe architecture of the package being deployed.
cachestrno--cacheZarf’s cache directory.
tmpdirstrno--tmpdirThe directory zarf unpacks the init package into.
timeoutstrno--timeoutHow long zarf waits for a Helm operation, as a Go duration such as 30m.
public_keystrno--keyThe public key the init package’s signature is verified against.
verifystrno--verifyWhen to verify the init package’s signature. One of never, if-possible, always.
valueslist of strno--valuesValues files to apply, one flag per entry.
set_valuesdictno--set-valuesValues to set, as a mapping. Rendered one flag per entry, sorted, so the same parameters always render the same command line.
set_variablesdictno--set-variablesZarf variables to set, as a mapping.
log_levelstrno--log-levelZarf’s log level.
log_formatstrno--log-formatZarf’s log format. Defaults to json, which is the format the component progress is read out of. Overriding it costs the progress display its component names, and changes nothing else about the run.

Notes

  • Set run_once: true and delegate_to on the task. One zarf init initialises the whole cluster, so a play over the cluster’s own inventory would otherwise initialise it once per host.
  • Set no_log: true on the task. A binary module has no per-parameter no_log, so the task-level setting is what suppresses the arguments and the result.
  • Check mode reports the task as skipped. zarf init has no dry run, so there is nothing honest to report instead.
  • A parameter left unset renders no flag, so whatever zarf’s own config file sets still applies. That is why plain_http: false and omitting plain_http differ.
  • Credentials given as parameters are rendered as flags, which puts them in the process table for the life of the run. Put them in a zarf config file and name it with zarf_config to keep them out of it.
  • The zarf that does the work is linked into the module, so there is no version to check and nothing to install. It is reported as zarf.version in the result.

Example

- name: Initialise the cluster
  colonel_byte.zarf.zarf_init:
    init_package: /srv/staging/zarf-init-amd64-v0.85.0.tar.zst
    kubeconfig: /etc/rancher/rke2/rke2.yaml
    storage_class: local-path
    components: zarf-registry,zarf-agent
    timeout: 30m
  delegate_to: localhost
  run_once: true
  no_log: true
  register: init_result

- name: Report which components the init package deployed
  ansible.builtin.debug:
    var: init_result.zarf.componentsRan

- name: Initialise the cluster with credentials zarf reads from its own config file
  colonel_byte.zarf.zarf_init:
    init_package: /srv/staging/zarf-init-amd64-v0.85.0.tar.zst
    kubeconfig: /etc/rancher/rke2/rke2.yaml
    zarf_config: /etc/zarf/zarf-config.yaml
  delegate_to: localhost
  run_once: true
  no_log: true

- name: Initialise the cluster from a custom init package under a name of its own
  colonel_byte.zarf.zarf_init:
    init_package: /srv/staging/our-init-package.tar.zst
    kubeconfig: /etc/rancher/rke2/rke2.yaml
  delegate_to: localhost
  run_once: true
  no_log: true

- name: Initialise the cluster from an init package held in a registry
  colonel_byte.zarf.zarf_init:
    init_package: oci://registry.bubbles.test/zarf/init:v0.85.0
    kubeconfig: /etc/rancher/rke2/rke2.yaml
  delegate_to: localhost
  run_once: true
  no_log: true