Update go.mod module line and all dependencies from forge.lthn.ai to dappco.re paths (core v0.5.0, log v0.1.0, io v0.2.0). Update all .go import paths. Rewrite cmd/ansible/ for new core.Command API replacing the cobra-based CLI integration. Update documentation references. Co-Authored-By: Virgil <virgil@lethean.io>
1.6 KiB
1.6 KiB
Executor
Module: dappco.re/go/core/ansible
The Executor is the main playbook runner. It manages SSH connections, variable resolution, conditional evaluation, loops, blocks, roles, handlers, and module execution.
Execution Flow
- Parse playbook YAML into
[]Play - For each play:
- Resolve target hosts from inventory (apply
Limitfilter) - Merge play variables
- Gather facts (SSH into hosts, collect OS/hostname/kernel info)
- Execute
pre_tasks,roles,tasks,post_tasks - Run notified handlers
- Resolve target hosts from inventory (apply
- Each task goes through:
- Tag matching (
Tags,SkipTags) - Block/rescue/always handling
- Include/import resolution
whencondition evaluation- Loop expansion
- Module execution via SSH
- Result registration and handler notification
- Tag matching (
Templating
Jinja2-like {{ var }} syntax is supported:
- Variable resolution from play vars, task vars, host vars, facts, registered results
- Dotted access:
{{ result.stdout }},{{ result.rc }} - Filters:
| default(value),| bool,| trim - Lookups:
lookup('env', 'HOME'),lookup('file', '/path')
Conditionals
when supports:
- Boolean literals:
true,false - Registered variable checks:
result is success,result is failed,result is changed,result is defined - Negation:
not condition - Variable truthiness checks
SSH Client Features
- Key-based and password authentication
- Known hosts verification
- Privilege escalation (
become/sudo) with password support - File upload via
cat(no SCP dependency) - File download, stat, exists checks
- Context-based timeout and cancellation