Snapshot
The Polycrate workspace snapshot captures resolved workspace, block, and action config for Ansible and debugging via workspace snapshot and run --snapshot.
Before every action run, Polycrate generates a workspace snapshot — a complete, resolved YAML capture of the workspace, block, and action configuration. This snapshot makes runs deterministically traceable and supplies the top-level variables for Ansible playbooks.
How the Snapshot Works
graph TB
Start[polycrate run block action] --> Load[Load workspace + secrets.poly]
Load --> Merge[Resolve inheritance & deep-merge]
Merge --> Snap[Generate snapshot YAML]
Snap --> Mount[Mount into container via POLYCRATE_WORKSPACE_SNAPSHOT_YAML]
Mount --> Vars[Ansible vars plugin exposes workspace / block / action]
Vars --> Exec[Ansible playbook runs]
Contents of a Snapshot
workspace: Complete workspace configuration (name,organization,config), all resolved blocks, and the file paths toinventory.ymlandartifacts/secrets/kubeconfig.yml(not their contents).block: The currently executed block after inheritance and merging withsecrets.poly, includingartifactsandsecretspaths.action: Metadata andaction.config(including any--setoverrides) for the invoked action.env&mounts: All environment variables passed to the container (includingPOLYCRATE_WORKSPACE,POLYCRATE_WORKSPACE_SNAPSHOT_YAML,KUBECONFIG,K8S_AUTH_KUBECONFIG,ANSIBLE_INVENTORY) as well as host-to-container mounts.
Example Snapshot (Abbreviated)
workspace:
name: acme-production-1
organization: acme
config:
image:
reference: cargo.ayedo.cloud/library/polycrate
version: "0.71.0"
blocksroot: blocks
artifactsroot: artifacts
secretsroot: artifacts/secrets
containerroot: /workspace
inventory:
path: inventory.yml
localpath: /home/user/.polycrate/workspaces/acme/acme-production-1/inventory.yml
containerpath: /workspace/inventory.yml
kubeconfig:
path: artifacts/secrets/kubeconfig.yml
localpath: /home/user/.polycrate/workspaces/acme/acme-production-1/artifacts/secrets/kubeconfig.yml
containerpath: /workspace/artifacts/secrets/kubeconfig.yml
block:
name: postgres
kind: k8sapp
version: 1.8.0
from: cargo.ayedo.cloud/ayedo/k8s/cloudnative-pg:1.8.0
config:
namespace: databases
instances: 3
action:
name: install
playbook: install.yml
env:
POLYCRATE_WORKSPACE: /workspace
POLYCRATE_WORKSPACE_SNAPSHOT_YAML: /tmp/polycrate-snapshot.yml
KUBECONFIG: /workspace/artifacts/secrets/kubeconfig.yml
K8S_AUTH_KUBECONFIG: /workspace/artifacts/secrets/kubeconfig.yml
ANSIBLE_INVENTORY: /workspace/inventory.yml
Inspecting a Snapshot
# Print the workspace snapshot
polycrate workspace snapshot
# Print the action snapshot (without executing the action)
polycrate run postgres install --snapshot
# Write to a file for analysis or filter with yq
polycrate run postgres install --snapshot | yq '.block.config'
Using the Snapshot in Ansible Playbooks
The Ansible vars plugin bundled in the Polycrate container loads the snapshot file automatically from POLYCRATE_WORKSPACE_SNAPSHOT_YAML and exposes workspace, block, action, and transaction directly as top-level variables:
- name: Deploy application
hosts: localhost
gather_facts: false
tasks:
- name: Display resolved parameters
ansible.builtin.debug:
msg: "Deploying {{ block.name }} into namespace {{ block.config.namespace }} (workspace {{ workspace.name }})"
Debugging Checklist
When an action behaves unexpectedly, polycrate run <block> <action> --snapshot gives immediate clarity:
- Were all values from
block.poly,workspace.poly, andsecrets.polymerged as expected? - Do
workspace.inventory.containerpathandworkspace.kubeconfig.containerpathpoint to the expected files? - Did
--setoverrides land correctly underaction.config?
See Also
- Inheritance — How block configurations are merged
- Ansible — Using snapshot variables in playbooks
- The Polycrate Container — Environment variables and mounts inside the container