Configuration Overview
Xec's configuration system provides a powerful, declarative way to define your infrastructure, automation tasks, and execution environments. Using a simple YAML format, you can describe complex workflows, manage multiple environments, and automate repetitive tasks across diverse infrastructure.
Philosophy
Xec's configuration follows several key principles:
1. Declarative Over Imperative
Define what you want to achieve, not how to achieve it. Xec handles the implementation details.
# Declarative: Define the desired state
tasks:
deploy:
description: Deploy application to production
target: production-servers
steps:
- command: docker-compose up -d
2. Convention Over Configuration
Sensible defaults minimize boilerplate while allowing customization when needed.
# Minimal configuration - uses conventions
targets:
hosts:
web-server:
host: web.example.com
# Port defaults to 22, username to current user
3. Composability
Build complex configurations from simple, reusable components.
# Compose configurations through profiles
profiles:
production:
extends: base
vars:
environment: production
replicas: 3
4. Progressive Disclosure
Start simple, add complexity only when needed.
# Simple start
tasks:
backup: rsync -av /data /backup
# Add complexity as needed
tasks:
backup:
description: Backup data with retention
schedule: "0 2 * * *"
steps:
- command: rsync -av /data /backup/$(date +%Y%m%d)
- command: find /backup -mtime +7 -delete
Configuration Hierarchy
Xec loads and merges configurations from multiple sources in a specific order:
- Built-in Defaults - Xec's internal defaults
- Global Configuration -
~/.xec/config.yaml
- Project Configuration -
.xec/config.yaml
in project root - Environment Variables -
XEC_*
prefixed variables - Profile Configuration - Profile-specific overrides
- Command-line Arguments - Runtime overrides
Later sources override earlier ones, allowing flexible customization at different levels.