Configure Command Override
The command setting allows you to override the executable that Atmos uses to run Terraform, Helmfile, Packer, or Ansible commands. This is useful for using alternative tools like OpenTofu, custom wrappers, or specific binary versions.
Use Cases
- OpenTofu: Use
tofuinstead ofterraformfor your infrastructure. - Custom Wrappers: Use wrapper scripts that add logging, timing, or other functionality.
- Version Management: Point to specific binary versions managed by tools like
tfenvorasdf. - Testing: Use mock binaries during testing or development.
Configuration Scopes
The command setting can be defined at two levels:
Component-Type Level
Set the command for all components of a type:
# stacks/orgs/acme/_defaults.yaml
terraform:
command: tofu
helmfile:
command: /usr/local/bin/helmfile
Component Level
Override the command for a specific component:
components:
terraform:
legacy-module:
command: terraform # Use terraform instead of tofu for this component
vars:
# ...
Examples
Using OpenTofu
All Terraform components will now use tofu instead of terraform.
Using Version Manager Shims
Custom Wrapper Script
Example wrapper script:
#!/bin/bash
# /opt/scripts/terraform-wrapper.sh
# Log command execution
echo "[$(date)] Running: terraform $@" >> /var/log/terraform.log
# Execute terraform with timing
time terraform "$@"
exit_code=$?
# Log completion
echo "[$(date)] Completed with exit code: $exit_code" >> /var/log/terraform.log
exit $exit_code
Mixed Tool Usage
Use different tools for different components:
Environment-Specific Commands
Helmfile Command Override
Packer Command Override
Ansible Command Override
The command setting for Ansible only affects non-playbook subcommands (e.g., atmos ansible version).
The atmos ansible playbook subcommand always uses the ansible-playbook binary. To use a custom
ansible-playbook path, ensure it is available on your PATH or use a wrapper/symlink.