Zero is a cross-platform configuration management system written in Go, inspired by tools like Chef, Puppet, and Ansible but designed to be simpler and more portable.
- Custom, easy-to-read DSL for defining system configurations
- Cross-platform support (Windows, Linux, macOS)
- Directory-based organization for platform-specific configurations
- Variables and templating
- Dependency management with intuitive syntax
- Idempotent operations
- Declarative resource model
-
Clone the repository
git clone https://github.com/dangerclosesec/zero.git cd zero -
Build the binary
go build -o zero ./cmd/zero -
Move the binary to your PATH (optional)
sudo mv zero /usr/local/bin/
-
Create a simple configuration file
example.cfg:// Define a variable variable "web_dir" { value = "/var/www/html" } // Ensure web directory exists file "$web_dir" { state = "directory" owner = "www-data" group = "www-data" mode = "0755" } // Create index file file "$web_dir/index.html" { content = "<html><body><h1>Hello from zero!</h1></body></html>" owner = "www-data" group = "www-data" mode = "0644" depends_on [ file {"$web_dir"} ] } -
Generate a plan to see what changes would be made
zero --plan --config example.cfg -
Apply the configuration
zero --apply --config example.cfg
zero uses a directory-based structure for organizing configurations:
config/
├── default/ # Default configurations, shared across all platforms
│ ├── web.cfg # Common web server configuration
│ └── base.cfg # Base system configuration
├── linux/ # Linux-specific configurations
│ ├── nginx.cfg # Linux-specific nginx configuration
│ └── services.cfg # Linux-specific service configuration
├── darwin/ # macOS-specific configurations
│ ├── homebrew.cfg # macOS package management
│ └── launchd.cfg # macOS service management
└── windows/ # Windows-specific configurations
├── iis.cfg # Windows IIS configuration
└── features.cfg # Windows features configuration
main.cfg # Main configuration file that includes platform-specific configs
The main configuration file includes platform-specific files:
// Include all default/common configurations
include "config/default/*.cfg"
// Include platform-specific configurations
include_platform {
linux = "config/linux/*.cfg"
darwin = "config/darwin/*.cfg"
windows = "config/windows/*.cfg"
}
zero uses a custom, easy-to-read DSL for defining configurations.
Manages files and directories on the system. The path is specified as the resource name.
file "/etc/nginx/nginx.conf" {
content = file("templates/nginx.conf.tpl")
owner = "root"
group = "root"
mode = "0644"
depends_on [
package {"nginx"}
]
}
Manages software packages using the system's package manager.
package "nginx" {
name = "nginx"
state = "installed" // installed, removed, latest
version = "1.18.0" // Optional
}
Manages system services across different init systems (systemd, upstart, launchd, Windows Services).
service "nginx" {
name = "nginx"
state = "running" // running, stopped, restarted, reloaded
enabled = true // Start at boot
depends_on [
file {"/etc/nginx/nginx.conf"}
]
}
Manages Windows features using DISM or PowerShell.
windows_feature "iis" {
name = "Web-Server"
state = "installed" // installed, removed
}
Define and use variables for reusable values.
variable "web_root" {
value = "/var/www/html"
}
file "$web_root/index.html" {
content = "<html><body><h1>Hello World</h1></body></html>"
}
Define reusable templates for configuration files.
template "default_site" {
content = "server {\n listen 80;\n root $web_root;\n index index.html;\n}"
}
file "/etc/nginx/sites-enabled/default" {
content = template("default_site")
}
Include other configuration files.
include "config/default/*.cfg"
Include files based on the current platform.
include_platform {
linux = "config/linux/*.cfg"
darwin = "config/darwin/*.cfg"
windows = "config/windows/*.cfg"
}
Specify dependencies between resources with an intuitive syntax.
depends_on [
file {"/etc/nginx/nginx.conf"},
package {"nginx"}
]
Specify platform-specific resources using the when block:
when = {
platform = ["linux", "darwin", "windows"]
}
zero provides comprehensive service management across different platforms:
Automatically detects and uses systemd, upstart, or SysV init:
service "nginx" {
name = "nginx"
state = "running"
enabled = true
}
Uses launchd for service management:
service "nginx" {
name = "org.nginx.nginx"
state = "running"
enabled = true
}
Manages Windows services:
service "nginx" {
name = "nginx"
state = "running"
enabled = true
}
zero [options]
Options:
--config string Path to the configuration file
--plan Show what changes would be made
--apply Apply the configuration
--verbose Enable verbose output
Complete examples are available in the examples directory.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.