zester
Guides

Overview

States are the core of Zester's configuration management. A state declares the desired configuration of a system resource — a file that should exist, a package that should be installed, a command that should have been run — and Zester ensures the actual system matches that declaration.

States are idempotent: applying the same state twice produces the same result. The engine checks the current system first and only makes changes when the actual state diverges from the desired state.


How States Work

Every state follows a three-phase lifecycle:

  1. Check — inspect the system and determine whether changes are needed, without modifying anything.
  2. Apply — make the system match the desired state.
  3. Revert — undo the changes made by Apply, restoring the previous state.

States declare dependencies on other states using requisites (require, watch, onchanges, onfail, prereq, listen, and their inverse _in forms). Zester builds a Directed Acyclic Graph (DAG) from these dependencies and executes states in topological order, running independent states in parallel.


Section Contents


Key Concepts

ConceptDescription
StateA single idempotent configuration action (e.g., ensure a file exists)
ModuleThe type of resource a state manages (file.managed, cmd.run, pkg.installed)
State IDA unique identifier for a state instance within a state file
DAGDirected Acyclic Graph that determines execution order from requisite declarations (require, watch, onchanges, onfail; listen, prereq, and _in forms are rewritten into these at compile time)
LevelA set of states with all dependencies satisfied that can execute in parallel
RunModeThe execution mode: Apply (default), Check (dry run), or Revert (rollback)

Quick Example

# /srv/zester/states/webserver/init.zy
install_nginx:
  pkg.installed:
    - name: nginx
    - refresh: true

deploy_config:
  file.managed:
    - path: /etc/nginx/nginx.conf
    - source: /srv/zester/files/nginx.conf
    - mode: "0644"
    - user: root
    - group: root
    - require:
      - pkg.installed:install_nginx

restart_nginx:
  cmd.run:
    - command: systemctl restart nginx
    - creates: /var/run/nginx.pid
    - require:
      - file.managed:deploy_config

This state file installs nginx, deploys a configuration file, and restarts the service — with explicit dependency ordering ensuring they execute in the correct sequence.

On this page