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