Skip to content

ansible: entry-list play bodies + ansible-applier - #5

Merged
polyedre merged 1 commit into
main-updatesfrom
ansible-entry-grammar
Sep 5, 2026
Merged

ansible: entry-list play bodies + ansible-applier#5
polyedre merged 1 commit into
main-updatesfrom
ansible-entry-grammar

Conversation

@polyedre

@polyedre polyedre commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

Rework the Ansible surface so an inventory reads as a list of declarations, with functions reserved for sugar and control flow.

  • One entry grammar for every play-body form (tasks, as, each, only, handlers):
    • ("Name" (module (arg val) …) #:keyword val …) declares a task, in YAML order (name, module dict, task-level keywords).
    • An entry whose head is a symbol is a Scheme expression whose task(s) splice in, so helpers drop in where repetition earns them.
    • Bare module symbols resolve to ansible.builtin.<module>; dotted names are taken as written.
  • as is now a body form taking a bare user symbol ((as root …)), still nesting with innermost-wins.
  • each/only replace map/if plumbing; task remains for a single task outside a body.
  • Removes the task/handler record macros, the as procedure and the example's local cat/tasks/copy helpers.
  • examples/ansible.scm rewritten as one declaration list per host (358 → 227 lines); rendered playbook is byte-identical to before except that task-level keys (when, register) now follow the module dict.
  • Docs and CHANGELOG updated; two checks for the grammar added to test.scm.

Applier: hexol apply runs ansible-playbook

  • ansible-applier #:inventory (path | state alist) writes deploy/playbook.json and deploy/inventory.json (state alist converted to Ansible all/hosts/children shape) and runs ansible-playbook -i INV PB …. --dry-run maps to --check --diff; hexol diff is refused (ansible has no drift exit code).
  • hexol apply passes the first flag it does not own, and everything after it, to the appliers via the new applier-args parameter:
    hexol apply -i examples/ansible.scm --list-tasks --limit web1.acme.example
    
  • examples/ansible.scm registers (appliers ("ansible" (ansible-applier #:inventory inv))).
  • Drops the tracked deploy/golden/ files: deploy/ is generated output and already gitignored.

Test plan

  • make build
  • guile -L . test.scm — all checks passed (new ansible checks included)
  • make test-examples — all example renders passed
  • guile -L . test/apply-mode.scm — ansible applier checks (PATH shim) pass
  • guix shell ansible -- ./bin/hexol apply -i examples/ansible.scm --list-tasks --limit web1.acme.example lists play CI: provision from manifest.scm via Guix #1 only
  • hexol render -o ansible -i examples/ansible.scm diffed against pre-change output: identical modulo key order noted above
  • make test in full fails locally on test/import.scm (Unbound variable: make-yaml_parser_t, libyaml FFI missing in this environment) — pre-existing, unrelated

🤖 Generated with Claude Code

@polyedre
polyedre force-pushed the ansible-entry-grammar branch from 72f3a04 to ad1ca7e Compare September 5, 2026 14:22
`(appliers ("ansible" (ansible-applier #:inventory inv)))` writes the
playbook and inventory JSON under deploy/ and runs ansible-playbook on them;
--dry-run maps to --check --diff, diff mode is refused (no drift exit code).

`hexol apply` hands the first flag it does not own and everything after it
to the appliers through the `applier-args` parameter, so
`hexol apply -i examples/ansible.scm --list-tasks --limit web1.acme.example`
reaches ansible-playbook as typed.

Drop the tracked deploy/golden files: deploy/ is generated output and
already ignored.
@polyedre
polyedre force-pushed the ansible-entry-grammar branch from ad1ca7e to 08c55ed Compare September 5, 2026 15:51
@polyedre polyedre changed the title ansible: play bodies are entry lists (tasks/as/each/only/handlers) ansible: entry-list play bodies + ansible-applier Sep 5, 2026
@polyedre
polyedre merged commit 52f414f into main-updates Sep 5, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant