Skip to main content

Using Ansible

Atmos natively supports opinionated workflows for Ansible. Ansible provides agentless automation for configuration management, application deployment, and infrastructure orchestration.

For a complete list of supported commands, please see the Atmos ansible documentation.

Stack Configuration

The schema for configuring Ansible components in Atmos stacks:

components:
ansible:
<component_name>:
vars: {}
env: {}
settings:
ansible:
playbook: <playbook_file>
inventory: <inventory_source>
metadata: {}
command: ansible # Base command (playbook subcommand always uses ansible-playbook)
hooks: {}

Variable Handling

Atmos generates a YAML variables file from the vars section and passes it to ansible-playbook using --extra-vars @<filename>. This makes all stack variables available in your playbooks.

# Stack manifest
components:
ansible:
webserver:
vars:
app_name: myapp
app_port: 8080
# Playbook can reference these directly
- name: Deploy app
hosts: webservers
tasks:
- name: Show config
ansible.builtin.debug:
msg: "Deploying {{ app_name }} on port {{ app_port }}"

Playbook and Inventory

Configure the playbook and inventory in the stack manifest or via command line flags:

components:
ansible:
webserver:
settings:
ansible:
playbook: site.yml
inventory: inventory/production

Command-line flags take precedence over stack manifest settings:

atmos ansible playbook webserver -s prod --playbook deploy.yml -i inventory/staging

Try It

Explore a minimal, working example demonstrating how stack variables are passed to Ansible playbooks.

atmos Ansible playbook
 
00:00.0 / 00:00.0

Example: Ansible Hello World

Minimal Atmos setup demonstrating how stack variables are passed to Ansible playbooks.

Learn more in the Ansible Playbook Command docs.

What You'll See

  • Ansible component configuration in Atmos stacks
  • Variables passed from stack manifests to playbooks via --extra-vars
  • Catalog pattern for shared defaults with per-environment overrides

Try It

cd examples/demo-ansible

# List all stacks
atmos list stacks

# Describe the hello-world component in dev
atmos describe component hello-world -s dev

# Run the playbook in dev
atmos ansible playbook hello-world -s dev

# Run the playbook in prod (different vars)
atmos ansible playbook hello-world -s prod

Key Files

FilePurpose
atmos.yamlAtmos configuration with Ansible component path
stacks/deploy/Per-environment stack files (dev, prod)
stacks/catalog/Shared component defaults
components/ansible/hello-world/Ansible playbook and inventory