Skip to main content

Module groups

Module groups 

Source
Expand description

Shared machine fields: common: for every machine, groups: for some. A spec that gives five servers the same Windows block writes it once:

common:
  vm: { os: debian@12 }
  resources: { cpus: 2, memory_mb: 2048 }
groups:
  servers:
    members: [dc01, dc02, srv02]        # machine names, globs (ws*), other groups
    vm: { os: windows-server@2019 }

Any field a group may share deep-merges into its members: a machine’s own value wins over its groups’, a group’s over common:, and between groups the most specific one (a group that is a member of another) wins; otherwise the later declared. docker: and vm: only complete an implementation the machine declares itself (even as vm: {}), so a shared vm: never turns a machine into a VM it wasn’t. Groups also become Ansible inventory groups, which a provisioner’s playbook can target.

Expansion happens on the YAML before the spec is parsed, so every reader of a Spec sees finished machines; the typed common and groups stay in the spec for validation, the inventory and the snapshot.

Functions§

expand
Folds common: and groups: into the machines of a spec document (the YAML, parsed): a machine’s own value wins over its groups’ (the most specific first), and theirs over common:. Unknown members are left for validation to report.
matches
Whether pattern (a name, or a glob with *) matches name.
members
The machines of a group: its member names and globs, and the members of the groups it names (recursively, cycles stopped). In spec order.
problems
The groups’ problems: a reserved or taken name, a member that names nothing, a cycle.