Manage secrets: generate, template, import, fetch, rotate¶
This page shows how to give a release every secret value it needs (passwords,
connection strings, config files that embed a password, a private CA and its
certificates) without writing any of them yourself, how to take values from
an external source (a SOPS file, HashiCorp Vault, AWS Secrets Manager), and how
to import, inspect and rotate them. The local secrets a machine or a Nix host
needs (provider credentials, a cache’s signing key, an age identity) are set
up with piceli secrets status and setup: see Setting up a host’s secrets.
Maturity: preview. The [secrets.*] generator types and the
piceli release secret show command may still change before 1.0. The origin
labels and error codes listed here are what scripts should match on.
How it works¶
You declare generators in release.toml. When plan creates a release,
Piceli produces their values inside the private secret store (the state
directory, owner-only). Your composition function never sees a value: it gets
opaque references from ctx.secret(name) and binds them to manifest fields
with ResourceIntent.with_secret(pointer, reference). The values are written
into the cluster only when an approved plan runs.
Values are produced only after the plan is accepted: if plan refuses
(for example because an object needs adoption), no value is generated, no
import source is read, openssl does not run and the store gets no new version.
External sources are the exception to “no source is read”: they are read at
every plan to detect a changed value, but nothing is stored until the plan is
accepted (see External sources).
A new release carries over every value from the latest release made with the same generator settings, so values are stable across releases until you rotate them.
Prerequisites¶
A working
release.tomland composition (see Releases from a spec (piceli release)).For
tls-self-signedandtls-ca: anopensslbinary at an absolute path (default/usr/bin/openssl; LibreSSL works too).For external sources: the
sopsbinary (sops), a reachable Vault and a token (vault), orpip install "piceli[aws]"and AWS credentials (aws-secrets-manager). See External sources.
Steps¶
Declare the generators. This example gives a cache a password, a connection string, a config file and TLS certificates signed by one private CA:
[secrets.cache_password] type = "random" bytes = 32 [secrets.cache_url] type = "template" template = "rediss://:{cache_password}@cache:6380/0" [secrets.cache_conf] type = "template" template = """ tls-port 6380 port 0 requirepass {cache_password} tls-cert-file /run/private/tls.crt tls-key-file /run/private/tls.key tls-ca-cert-file /run/private/ca.crt """ [secrets.ca] type = "tls-ca" leaves = { cache = ["cache", "cache.shop.svc"], api = ["api"] }
Bind the outputs in the composition. Each generator has one or more outputs (the table below lists them). Bind them into a Secret; your containers mount it as files or read keys as environment variables, and init containers only need to copy files:
keys = { "url": "cache_url", "redis.conf": "cache_conf", "ca.crt": "ca.ca.crt", "tls.crt": "ca.cache.crt", "tls.key": "ca.cache.key", } secret = ResourceIntent.from_manifest( { "apiVersion": "v1", "kind": "Secret", "metadata": {"name": "cache-auth-1", "namespace": ctx.namespace}, "data": {key: "<private>" for key in keys}, } ) for key, output in keys.items(): secret = secret.with_secret(f"/data/{key}", ctx.secret(output))
Every exposed output must be bound, except outputs a template uses (
cache_passwordabove reaches the cluster throughcache_urlandcache_conf, so binding it is optional).Plan and apply.
$ piceli release plan --spec release.toml release shop-5c1e0f7a9d2b (create, apply): 2 create create Secret/cache-auth-1 create Deployment/cache secret ca: generated secret cache_conf: rendered secret cache_password: generated secret cache_url: rendered plan hash: 9f3c…d41a (valid until 2026-09-24T17:24:59+00:00) $ piceli release apply --spec release.toml --approve 9f3c…d41a apply shop-5c1e0f7a9d2b: ready
The next release shows
secret cache_password: carried:shop-5c1e0f7a9d2b.
Generators¶
|
Produces |
Outputs ( |
|---|---|---|
|
|
|
|
an RSA key and a self-signed certificate |
|
|
a private CA and leaf certificates it signs |
|
|
text with placeholders for other outputs |
|
|
an existing value from a file, an environment variable or a live Secret |
|
|
a public value (a user name, a port) |
|
|
one value of a SOPS-encrypted file, or the whole file |
|
|
one key of a HashiCorp Vault KV v2 secret |
|
|
an AWS Secrets Manager secret, or one key of its JSON value |
|
Every generator takes encoding = "base64" (the default, for Secret.data)
or "raw" (for stringData; the value must be UTF-8 text).
tls-ca¶
[secrets.ca]
type = "tls-ca"
common_name = "shop private CA" # default "piceli private CA"
ca_days = 3650 # CA validity (default 3650)
days = 365 # leaf validity (default 365, at most ca_days)
rsa_bits = 2048 # 2048, 3072 or 4096
openssl = "/usr/bin/openssl" # absolute path; add openssl_sha256 to pin the binary
[secrets.ca.leaves]
cache = { dns_names = ["cache", "cache.shop.svc"], ip_addresses = ["10.0.0.7"] }
api = ["api"] # short for { dns_names = ["api"] }
Clients trust one file, ca.ca.crt. Leaves are server and client
certificates (serverAuth, clientAuth) with the DNS names and IPs as
subject alternative names. Adding a leaf later keeps the CA and the other
leaves and signs only the new one (origin signed:<release>). Changing the
CA settings, or --rotate ca, creates a new CA and new leaves. The CA key
never reaches a composition; the owner can read it with secret show.
Piceli runs openssl req and openssl x509 -req with an explicit argument
list (no shell) in a private temporary directory that is deleted afterwards.
template¶
[secrets.cache_url]
type = "template"
template = "rediss://:{cache_password}@cache:6380/0"
A placeholder is {output} or {secret:output}, where output is any
exposed output from the table above: {cache_password}, {ca.ca.crt},
{web-tls.crt}. {{ and }} are literal braces; any other brace is an error.
Templates are rendered inside the private store in dependency order, and a
template may use another template. When a value a template uses changes (by
rotation, for example), the template is rendered again with the new value.
Use a template to build a CA bundle from several certificates:
template = "{ca.ca.crt}{old-ca.ca.crt}".
import¶
[secrets.cache_password]
type = "import"
secret = { name = "legacy-cache", key = "password" } # a live Secret in the target namespace
# file = "secrets/cache-password.txt" # or a file, relative to the spec
# env = "CACHE_PASSWORD" # or an environment variable
# trim_newline = true # file/env: drop one trailing newline
# rotate = "random" # what --rotate does: "random" or "reimport"
# bytes = 32 # size of a random rotation
Use an import to keep a service with existing data working across its first release: the value it already uses is imported and becomes the first version. A live Secret is read through the release’s own kubeconfig and context, and only when a release is created. Later releases carry the value over, so the source can be removed after the first release. Changing the source (another file, variable or Secret) imports again.
--rotate NAME replaces an imported value: with rotate = "random" (the
default) Piceli generates a new random token; with rotate = "reimport" it
reads the source again (useful when another system rotates the value).
static¶
[secrets.cache_user]
type = "static"
value = "shop"
A public value that templates and compositions can reference like the others.
It is stored like a secret but is not secret: it appears in release.toml.
External sources¶
Maturity: preview. sops, vault and aws-secrets-manager take a value
that another system owns. They follow the same opaque-reference model as the
generators: the composition gets a reference, the value goes only into the
private store and the cluster.
How they differ from import:
Read at every plan. A source may have been rotated upstream, so
plan(anddiff) reads every external source before it names the release.--rollback-todoes not read them: it re-applies the stored versions.A new version only when the value changed. Each value is reduced to a keyed digest: HMAC-SHA256 under a random key that Piceli creates in the state directory (
secret-sources.key, owner-only). The digest is part of the release fingerprint and of the carry-over bookkeeping. An unchanged value re-plans the same release and stores nothing; a changed value names a new release that stores a new version (originfetched) and carries the other values over. Without the key, the digest says nothing about the value. Deleting the key only means the next plan stores the values again.A refused plan stores nothing. Values stay in memory until the plan is accepted, as with every generator.
Never printed. Values never reach the plan, the journal, receipts, logs or error messages;
sops’s error output is discarded and Vault or AWS error bodies are never shown, only a category (HTTP 403,AccessDeniedException).
sops¶
[secrets.db_password]
type = "sops"
file = "secrets/prod.enc.yaml" # relative to the spec
key = "db.password" # or ["db", "password.v2"] when a key has a dot
# format = "yaml" # yaml, json, dotenv, ini; "binary" takes the whole file (no key)
# sops = "sops" # a name looked up in PATH, or an absolute path
# sops_sha256 = "sha256:…" # pin the binary's content
# pass_env = ["SOPS_AGE_KEY_FILE"] # variables sops may see besides PATH and HOME
# timeout_seconds = 30
Piceli runs sops --decrypt --output-type json [--input-type FORMAT] FILE
with an explicit argument list (no shell), no stdin, a timeout and an 8 MB
output limit, in the file’s directory. The process gets only PATH, HOME,
LANG=C and the variables named in pass_env, so age, PGP and cloud KMS
keys work as they do for sops itself (~/.config/sops/age/keys.txt,
SOPS_AGE_KEY_FILE, GNUPGHOME, AWS_PROFILE…) while nothing else of the
environment leaks in. A key must name a scalar (a string, number or boolean).
vault¶
[secrets.api_token]
type = "vault"
address = "https://vault.example:8200"
mount = "secret" # the KV v2 mount (default "secret")
path = "shop/api"
key = "token"
token_file = "/run/vault/token" # or: token_env = "VAULT_TOKEN"
# namespace = "team-a" # Vault Enterprise / HCP namespace
# version = 3 # pin a KV version; default: the latest
# ca_file = "certs/vault-ca.pem" # a private CA; TLS is always verified
# timeout_seconds = 10
One GET /v1/<mount>/data/<path> over verified TLS. The token is read from
token_file (a Vault agent sink, for example) or from the environment
variable named by token_env, and is sent only in the X-Vault-Token
header: it is never in the spec, a command line or a message. There is no
option to skip TLS verification; http:// is accepted only for a loopback
address (vault server -dev). Redirects are not followed and proxies are not
used.
aws-secrets-manager¶
[secrets.cloud_key]
type = "aws-secrets-manager"
secret_id = "shop/cloud" # a name or an ARN
region = "eu-west-1"
key = "key" # optional: one key of a JSON SecretString
# version_stage = "AWSPREVIOUS" # or version_id = "…"; default AWSCURRENT
# profile = "deploy" # a profile of the AWS config files
# endpoint_url = "https://vpce-….secretsmanager.eu-west-1.vpce.amazonaws.com"
# timeout_seconds = 10
Needs pip install "piceli[aws]" (botocore, imported only when such a secret
is read). Credentials come from botocore’s standard chain: environment,
profile, SSO, web identity (EKS, GitHub OIDC), instance or task role. A
SecretBinary value is taken as bytes (use the default base64 encoding).
AWS Secrets Manager is the cloud manager Piceli supports first: it is the
most widely used one, botocore is a single optional dependency whose
credential chain already covers CI (OIDC) and in-cluster roles, and its
Stubber lets Piceli test it without a network.
In a pipeline¶
from piceli.pipeline import AwsSecret, Secrets, Sops, Template, Vault
secrets = Secrets(
db_password=Sops(
"secrets/prod.enc.yaml", "db.password", pass_env=["SOPS_AGE_KEY_FILE"]
),
db_url=Template("postgres://shop:{db_password}@db/shop"),
api_token=Vault(
"https://vault.example:8200", "shop/api", "token", token_file="/run/vault/token"
),
cloud_key=AwsSecret("shop/cloud", region="eu-west-1", key="key"),
)
app.secret("external-1", {"db": secrets.ref("db_url")})
When the value changes¶
A changed value is a new version in a new release. Secrets are retained
objects, so bind it into a Secret with a new name, as for --rotate:
bump the generation in [values] (external-1 → external-2) and plan,
or declare it with versioned=True (see Versioned Secrets). Under
the same name, apply stops with retained-content-precondition-failed
and writes nothing. --rotate refuses an external source
(secret-rotation-refused): rotate it at the source and plan again.
--rollback-to re-applies the earlier release with its stored version.
Versioned Secrets¶
Piceli never rewrites a Secret, so a new value needs a Secret with a new
name. versioned=True does that for you, like the generated Secrets of
kustomize:
turn = app.secret("turn", {"turnserver.conf": ctx.secret("turn_conf")}, versioned=True)
app.deployment(
"relay", image=ctx.image("relay"), volumes={"/etc/turn": SecretVolume(turn)}
)
The Secret is named
turn-<hash>. The hash is 10 characters of a digest over the keyed fingerprints of the values (the same HMAC (hash-based message authentication code) aspiceli.io/secrets-digest), so the same values give the same name and the name tells nothing about a value.Every reference to
turn(volumes, projected volumes,env,envFrom,imagePullSecrets, Ingress TLS) is rewritten to that name. A new value is a new name, so the workloads roll in the same apply.The Secret is
immutable: trueand carriespiceli.io/versioned-from: turn.The plan shows the change, without values:
secret turn → turn-a1b2c3d4e5 (new value) delete turn-0f9e8d7c6b (no longer mounted)
The JSON output lists the same under
versioned_secrets.
Old versions. When a plan creates a new version, it deletes the older
versions of the same Secret that this release’s owner wrote and that no
object refers to. The version the running release mounts is kept: it is the
rollback target. So the previous version goes at the next change, and an
unchanged release deletes nothing. A Secret that another tool or owner
wrote is never deleted. --rollback-to re-creates a deleted version from
the state if it needs one.
When to use it. Config files that carry a secret (a server config with a
shared secret, a connection string), built with a template, an import,
a static value or an external source.
When not to. Generated passwords, keys and certificates (random,
tls-self-signed, tls-ca) keep their value until you rotate them, and an
empty state adopts them back from the live Secret by its declared name. A
versioned Secret that binds one directly is refused with
versioned-secret-generated: keep those in a plain app.secret(...). A
template over a random is allowed; if the state starts empty and the
random is bound nowhere else, it gets a new value, and with it a new
Secret.
Inspect a value¶
piceli release secret show NAME --spec release.toml [--key KEY] [--release NAME] [--reveal] [--json]
Invocation |
Prints |
|---|---|
|
metadata only (see below); never a value |
|
the value, exactly, on stdout |
|
asks you to type the secret name, then prints the value |
|
refuses with |
|
one output of a generator with several |
|
metadata plus |
Contract:
Reads the local state directory only; never contacts the cluster and never writes. The value goes to stdout only; nothing is written to stderr, logs, the journal or the catalog.
Defaults to the selected (last ready) release, otherwise the newest release;
--release NAMEpicks another. Values are decoded (no base64).--keytakes the output key within the generator:crt,key,ca.crt,ca.key,<leaf>.crt,<leaf>.key.Revealing is an owner action. Agents must not run it with
--reveal.Metadata fields:
secret,release,type,encoding,keys,internal,origin,first_release,first_origin, andsource(imports and external sources),rotate(imports) ordepends_on(templates).Exit codes:
0shown,2rejected:{"state": "rejected", "reason": "<code>", "message": …}on stdout (the value is never part of it).
Rotate a value¶
$ piceli release plan --spec release.toml --rotate cache_password
secret cache_password: rotated
secret cache_url: rendered
Rotation always creates a new release. Secrets are retained objects: Piceli
never rewrites an existing Secret, so put the rotated value into a Secret with
a new name (for example bump cache-auth-1 to cache-auth-2 through
[values]) and point the workloads at it. See the rotation notes in
Releases from a spec (piceli release). Templates and static values are not rotated themselves:
rotate what they use, or edit the spec. Editing a template changes the value
of the Secrets that hold it, so it also needs a Secret with a new name: the
plan refuses a new value under an existing name (retained-content-differs,
naming the Secret and the keys).
Workloads that read a Secret roll when its content changes, also when the
Secret keeps its name (for example one you deleted so the release creates it
again with the rotated value): their pod template carries
piceli.io/secrets-digest, a digest of keyed fingerprints of the values, so
the pods restart with the new value and a carried-over value rolls nothing.
See Roll pods when their configuration changes.
Origins in the plan¶
plan prints one line per generator, and the JSON output has the same values
under secrets:
Origin |
Meaning |
|---|---|
|
new value (first release, or the generator’s settings changed) |
|
read from the import source; this is the first version |
|
new value because of |
|
the same value as in that release |
|
|
|
a template, rendered from its current inputs |
|
an external source: the first value, or a value that changed at the source |
|
the value from the spec |
|
read back from a live Secret an earlier release wrote (see below) |
When the state starts empty¶
Generated values live in the state directory (state_dir, or the GitOps
controller’s state volume). A new state directory knows none of them: a
clone on another machine, a lost volume, a controller rescheduled to another
node. Before 0.23.0 its first plan generated new values, and apply then
failed with retained-content-precondition-failed on every generated Secret
the earlier release had created, because Piceli never rewrites a retained
Secret. Deleting those Secrets by hand rotated every password, token and the
private CA.
Now the plan adopts them. When no release in the state records a
random, tls-self-signed or tls-ca generator, and a Secret the
composition declares is live with that generator’s values, plan reads the
values from the Secret and records them in the state exactly as if it had
generated them. Nothing is rotated, deleted or written: the Secret plans as
no-op.
$ piceli release plan --spec release.toml
...
secret password: adopted from Secret credential (kept, not rotated)
secret ca: adopted from Secret turn-auth (kept, not rotated)
The JSON output shows "secrets": {"password": "adopted", ...} and
"secret_adoptions": [{"secret": "password", "from": ["credential"]}]. The
plan itself records each adopted generator with the Secret’s UID
(secret_adoptions in the plan), so the plan hash you approve covers the
adoption. piceli deploy prints [plan] secret password: adopted from Secret credential (no record in the state; values kept, not rotated), puts the same
list in its plan stage (and in the preview before images exist), and its
combined hash covers it. The release engine also logs one warning per
adopted generator. piceli release secret show NAME --json reports
origin: adopted; later releases carry the value as usual
(carried:<release>).
Only a Secret this release wrote is adopted. It must carry:
the
piceli.io/ownerannotation equal to the release owner ([release] owner, or the pipeline’sowner, by default the app name); aninherited_ownersid does not count;a
managedFieldsentry of the release’s field manager ([release] field_manager, by default the owner);the target namespace (discovery reads only that namespace).
A Secret without these marks (unlabelled, or written by another app,
environment or tool) is never adopted: the plan and apply refuse it exactly
as before (resource-requires-adoption for another owner,
retained-content-precondition-failed for different content).
The values must also be values the generator could make. The plan refuses
with secret-adoption-invalid when the live Secret has another key set than
the composition declares, a random value has another length or characters
than token_urlsafe(bytes) gives, a certificate or key is not PEM, or two
Secrets hold different values for the same output. It refuses with
secret-adoption-incomplete when only some of a generator’s values are live.
In both cases nothing is stored or written.
Adoption never replaces an explicit --rotate, and never applies when the
state already records the generator (its values then come from the state, or
new values are made when its settings changed). Imports, templates, static
values and external sources are not adopted: imports read their source
again, templates render from their (adopted) inputs.
The CA key of a tls-ca. The CA key is internal: Piceli never writes it
to a Secret, so an adopted CA has no key. The CA certificate and every leaf
are kept, and later releases carry them. Adding a leaf needs the key, so it
is refused with secret-adoption-incomplete: rotate the CA (--rotate ca)
into Secrets with new names when you need new leaves.
Setting up a host’s secrets¶
A declaration of machines and Nix hosts (A single NixOS host) needs local secrets that never go into Git: the cloud’s and the registrar’s credentials, the state passphrase, the cache’s signing key, the host’s age identity, its first-boot user data and the cache’s S3 key pairs. Two commands set them up from the declaration itself (0.25.0). Neither prints a value.
The cache’s signing key does not exist before setup makes it, so a new
declaration names the key without its public key:
cache = NixCache(key_name="example-cache-1", bucket=nix_bucket)
secrets status, secrets setup and infra plan (the bucket and its S3
pairs need no signing key) work with it. Whatever needs the public key
refuses with dev-nix-cache-key-unset until it is declared: dev nix build --publish, dev nix gc and host module. A composition with a
NixRelease of that cache still loads and its environments deploy; the
controller keeps that release rejected (dev-nix-cache-key-unset, in
gitops status and piceli targets) and publishes nothing for it, and
gitops enable warns about it. Step 3 puts the key setup prints in its place:
NixCache("example-cache-1:<base64>", bucket=nix_bucket).
See what the declaration needs.
$ piceli secrets status web_1.py NAME KIND STATE BY NEXT infomaniak provider-token incomplete owner piceli secrets provider infomaniak --prompt porkbun provider-token missing owner piceli secrets provider porkbun --prompt example-cache-1 nix-signing-key missing piceli piceli secrets nix-cache example-cache-1 --generate web-1-state state-key present piceli - web-1-age age-identity missing piceli piceli secrets age web-1-age --generate web-1-boot user-data missing owner piceli secrets user-data web-1-boot --prompt nix-cache-write s3-keys pending infra-apply piceli infra plan web_1.py:infra nix-cache-read s3-keys pending infra-apply piceli infra plan web_1.py:infra what each is for: infomaniak openstack API [infomaniak: one part of two stored, re-run `piceli secrets provider infomaniak --prompt`] web-1-age sops-nix on web-1; on host web-1 too: piceli host secrets web-1 puts it there; its age1 public key goes in .sops.yaml web-1-boot user data of web-1; read once, when infra apply creates web-1: store a short-lived key right before that apply nix-cache-read read S3 keys of bucket example-nix-cache; on host web-1 too: piceli host secrets web-1 writes it to /var/lib/piceli-host/cache.env [created by the next infra apply] ... backup: no backup yet; next: piceli secrets backup-key --out PATH --add warning: S3 key nix-cache-read (bucket example-nix-cache) is not read-only at openstack: hosts only read with it, but the cloud lets it write summary: 1 present, 2 pending, 4 missing, 1 incomplete; piceli secrets setup web_1.py walks through them
It reads every declaration in the module (
Infrastructure,Bucket,NixCache,NixHost,NixRelease,DevBuilds, and a composition’s clusters, whose credentials arepiceli loginprofiles), or one withweb_1.py:host. Each secret is:State
Meaning
presentStored and complete.
pendingA key pair the next
infra applycreates: the infrastructure has not applied it yet. Not an error.missingNot stored. A pair
infra applyalready created but this store lacks: the nextinfra planstores it again from the state.incompleteA credential that lacks a part (a Porkbun key pair stored as one value).
damagedUnreadable, readable by other users, of another kind, or a signing key whose public key is not
NixCache(public_key=).copyA signing key stored for a cache declared with
key_name=alone:put example-cache-1:<base64> into NixCache(public_key=);NEXTprints the public key again.not-neededThe user data of a server that exists: a plan reads it only to create the server again.
BYsays who makes it:owner(only you have it: you type it with--prompt),piceli(generated with--generate) orinfra-apply(piceli infra applycreates and stores it).NEXTis the exact command. The backup line tells whether a backup exists and is newer than every secret (stalenames the newer ones). Exit 0 means every secret is stored and complete, or pending; 1 that something is missing, incomplete, damaged or waits for its public key to be copied.--jsonprints the same as onepiceli.secrets-status.v1object (secrets, each withstate,created_by,next,purpose,where,build_host,detail;counts,complete,backup,warnings).Walk through what is missing.
piceli secrets setup web_1.pytakes the secrets in this order:Provider credentials, asked for part by part, as
piceli secrets providerasks for them (an identifier echoed, a secret not).The keys Piceli generates, after a
[Y/n]each: the state passphrase, the cache’s signing key and the host’s age identity. Only the public halves are printed; copy the signing key’s intoNixCache(public_key=...)and theage1...key into.sops.yaml.The user data, offered with a
[y/N]: a bootstrap key in it should be short-lived (single-use, expiring in an hour), so the default is to store it later, right beforeinfra apply.The S3 key pairs:
infra applycreates them; nothing happens here.A backup when none is current: the offline key (
backup-key), your own age recipient, then the backup itself. Each is skipped with an empty answer.
$ piceli secrets setup web_1.py 1. Provider credentials: only you have them infomaniak: OpenStack application credential (openstack API); application credential ID and application credential secret Step 1 of 2: Application credential ID. Where: the cloud's dashboard (Horizon): … Application credential ID: 0123456789abcdef0123456789abcdef Step 2 of 2: Application credential secret. Where: … Application credential secret (not echoed): stored infomaniak: application credential ID and application credential secret; no value was printed ... 2. Keys Piceli generates Generate nix-signing-key example-cache-1 now? [Y/n]: y generated example-cache-1 (nix-signing-key); the secret was not printed public key: example-cache-1:SRm8gJ5/1Ar3IoTsZn4jGAGWab2eao9d4zpNY1n6rec= put it in NixCache(public_key=...) in your declaration present: web-1-state (state-key) Generate age-identity web-1-age now? [Y/n]: y ... 3. User data: needed only when infra apply creates the server Store web-1-boot now? [y/N]: later, right before infra apply: piceli secrets user-data web-1-boot --prompt 4. S3 key pairs nix-cache-write: write S3 keys of bucket example-nix-cache, made by piceli infra apply; nothing to do here; next: piceli infra plan web_1.py:infra ... 5. Backup Offline backup key: a path outside the store (a USB drive), empty to skip: /Volumes/usb/piceli-offline.key ... copy: example-cache-1:SRm8gJ5/1Ar3IoTsZn4jGAGWab2eao9d4zpNY1n6rec= into NixCache(public_key=...) (example-cache-1) copy: age1tyz57d7pampk4pt8ry6vcxgdalz4tpj48jnux3y92u44f09rtfusahd42n into .sops.yaml (web-1-age) done: every secret Piceli can set up now is stored
A stored key is never replaced without a typed
y: a damaged one is offered for replacement with[y/N], and a signing key that only differs from the declaration prints its public key instead. Exit 0 means everything is stored but what is left for later on purpose (the user data, the pairsinfra applymakes); 1 that something still needs you.Copy the public keys into the declaration and
.sops.yaml: replacekey_name="example-cache-1"with the printed key (NixCache("example-cache-1:SRm8gJ5/...", bucket=nix_bucket)). Until thenpiceli secrets status web_1.pyshows the signing keycopy:example-cache-1 nix-signing-key copy piceli piceli secrets nix-cache example-cache-1and
presentonce the declaration names it. A declaration that names another key shows itdamaged.Right before the first apply, store the user data (
piceli secrets user-data web-1-boot --prompt), then plan and apply:infra applystores the S3 pairs, andstatusshows thempresent.A build host that publishes releases. With a
NixRelease(..., builder="mini"), the cache’s signing key and S3 write pair are made here (setup,infra apply), butpiceli builder serve --publishonminireads them frommini’s own store. Once they are present here,statusgives the command that carries them there (build_host: "mini"), and the steps are in Moving a build host’s keys there.
Without a terminal (scripts, agents), setup --yes generates the keys and
reads provider parts piped one per line, in the order status lists them;
stdin at its end skips them, and the user data and the backup are left for
later. --yes never replaces a key. --json prints one object per step
(state: stored, generated, copy, present, later, skipped,
needs-yes, kept, failed), then a summary with remaining, later and
copy.
If it fails¶
Refusals exit with code 2 and print {"state": "rejected", "reason": "<code>", "message": …} on stdout (0.4.0 changed this from
{"state": "refused", …}; see Contract changes in 0.4.0). No secret
version is left behind by a refused plan.
Code |
Cause |
Fix |
|---|---|---|
|
A template has a stray |
Write |
|
A placeholder names no exposed output (a typo, a multi-output generator without a key, or the internal CA key). |
Use a name from the outputs table, for example |
|
Templates reference each other in a loop (the message shows the loop). |
Break the loop. |
|
The import source is missing, empty or unreadable: file, variable, Secret or key, or the cluster refused the read (the category, such as |
Provide the source, fix the name or key, or grant |
|
A |
Use |
|
|
Rotate the values the template uses, edit the static value, or rotate an external value at its source. |
|
Vault answered 401/403 or the token file/variable is missing; AWS denied the request or found no credentials; |
Provide the token, AWS credentials or profile, or the key |
|
The SOPS file, Vault path, AWS secret or the key inside it does not exist, is empty or is not a scalar. |
Fix |
|
|
Install |
|
|
Check connectivity or raise |
|
A network or TLS verification error ( |
Read the category in the message and fix the source; retrying is safe. |
|
|
Check the |
|
|
Add |
|
|
Add |
|
|
Check the name; the message lists what exists. |
|
The state has no record of a generator, and the live Secret an earlier release wrote holds values it could not have made: another key set, a malformed value, or copies that differ. |
Fix or delete the live Secret, or rotate the generator into a Secret with a new name. |
|
Only some of a generator’s values are live (an adopted CA has no key, so it cannot sign a new leaf). |
Rotate the generator ( |
A composition that does not bind a declared output is refused with
declared secret inputs are not bound by the composition: […].