zester
GuidesModules

module

The module.* family of state modules.

ModuleSummary
module.runInvoke another registered state module by name (Salt-compatibility escape hatch).

All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.


module.run

Invoke another registered state module by name (Salt-compatibility escape hatch).

Source: pkg/state/modules/module/module_run.go


module.run is a Salt-compatibility escape hatch that invokes another registered state module by name. The target module is built at compile time with the supplied arguments and its Check/Apply/Revert are delegated to — so module.run is exactly as idempotent as its target.

It accepts arbitrary parameters, which are forwarded to the target module, and supports two forms:

  • Classic name: form — set name: to the target module (for example file.touch); every other non-name, non-directive key is forwarded as the target's config.
  • Dotted-key form (newer Salt style) — a single dotted key (for example file.touch:) names the target and its map value is the argument set.

If neither a name: nor a dotted <module.func>: key is present, the build fails with no target module. Requisite and generic-attribute keys (require, watch, onlyif, order, …) declared alongside the target are recognized as directives and carried through to the target — never mistaken for a dotted module key. The module.run state ID is passed to the target as ITS state ID, so the target's primary-parameter-defaults-to-ID convention applies to the module.run ID. Other states reference this one as module.run:<id> in their requisites — not by the wrapped target's name.


Parameters

This module takes no parameters of its own.


Effects

Check

Delegates to the target module's Check (the target is built once at compile time with the resolved arguments).

Apply

Delegates to the target module's Apply.

Revert

Delegates to the target module's Revert.


Examples

Wrap a state module under a descriptive ID (classic form)

name selects the target; the remaining keys (path, makedirs) are forwarded to file.touch.

mark-provisioned:
  module.run:
    - name: file.touch
    - path: /var/lib/myapp/.provisioned
    - makedirs: true

Dotted-key form with a requisite

The dotted key names the target; the requisite alongside it is carried through, never treated as the target.

refresh-cache:
  module.run:
    - cmd.run:
        command: apt-get update
    - onchanges:
      - "pkgrepo.managed:docker"

On this page