atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Add Native Ansible Support

Open Adrastopoulos opened this issue 5 months ago • 3 comments

what

  • Add native Ansible component support (ansible) across config, schema, stack processing, and exec.
  • Introduce atmos ansible with Terraform-style wiring and rich help:
    • run: execute ansible-playbook with component-scoped vars
    • inventory: run ansible-inventory (defaults to --list)
    • galaxy: run ansible-galaxy (defaults to install -r requirements.yml if no args)
    • doc: run ansible-doc
    • config: run ansible-config
    • vault: run ansible-vault
    • version: show ansible-playbook --version
  • Extend stack processing to merge components.ansible and settings.ansible:
    • settings.ansible.playbook and settings.ansible.inventory
    • components.ansible.command override and base path resolution
  • Add config flags/env + path utilities:
    • Flags: --ansible-command, --ansible-dir
    • Env: ATMOS_COMPONENTS_ANSIBLE_COMMAND, ATMOS_COMPONENTS_ANSIBLE_BASE_PATH
    • Working dir/varfile helpers for Ansible (<context>-<component>.ansible.vars.yaml)
  • CLI structure matches Terraform:
    • Centralized getAnsibleCommands in cmd/ansible_commands.go with detailed Long help and examples
    • ansibleRun mirrors terraformRun semantics, including -- passthrough and Atmos flag stripping

Examples:

# Run playbook with vars from stack/component
atmos ansible run web -s tenant/ue2/dev -- --check

# Inventory (defaults to --list)
atmos ansible inventory web -s tenant/ue2/dev

# Galaxy (defaults to install -r requirements.yml)
atmos ansible galaxy web -s tenant/ue2/dev

# Vault/doc/config passthrough
atmos ansible vault  web -s tenant/ue2/dev -- view group_vars/all/vault.yml
atmos ansible doc    web -s tenant/ue2/dev -- -l
atmos ansible config web -s tenant/ue2/dev -- dump

why

  • Parity with Terraform/Helmfile UX so teams can standardize IaC + config mgmt under Atmos.
  • Leverage Atmos deep-merge, settings, and ENV handling for repeatable Ansible runs.
  • Reduce boilerplate for varfiles/inventory, enforce consistent working dirs, and improve debuggability via structured logging.
  • Prepare for CI/CD and future hooks/pro integrations with consistent command surfaces and flag handling.

todos

  • [ ] documentation, website overview/subcommands, schema for settings.ansible/components.ansible, CLI markdown help, completions, etc
  • [ ] testing, e2e dry-run tests, ensure list components shows ansible
  • [ ] release/CHANGELOG entry

references

  • PR context and prior art for Ansible integration inspiration:
    • https://github.com/cloudposse/atmos/pull/1448
    • https://github.com/cloudposse/atmos/pull/1394

Adrastopoulos avatar Oct 01 '25 02:10 Adrastopoulos

I use atmos in my homelab to run terraform and packer and thought it would be nice to handle ansible as well. Ideally we'd take the best parts of this and @RoseSecurity's work in https://github.com/cloudposse/atmos/pull/1448 to get this done.

Adrastopoulos avatar Oct 01 '25 02:10 Adrastopoulos

  • [ ] Add docs

osterman avatar Oct 01 '25 03:10 osterman

💥 This pull request now has conflicts. Could you fix it @Adrastopoulos? 🙏

mergify[bot] avatar Oct 08 '25 16:10 mergify[bot]