# Container Config Sync: Keep Your Cluster in Harmony
## What's This All About?
This little tool helps you keep your container configurations (think `docker-compose.yml`) in sync across multiple servers. It's super useful when you want to make sure everything's running the same way across your cluster. Basically, it watches one "main" server and automatically copies changes to the others. We *highly* recommend running this thing in a container for easier setup and maintenance.
## What It Does
* **Config-Driven:** You tell it what to do with a simple `synchronizer.yml` file.
* **Auto-Sync:** Keeps an eye on your main server and pushes out any updates.
* **Docker or Podman? No Problem:** Works with either Docker or Podman.
* **Updates Like a Pro:** Automatically updates your containers when things change.
* **No Messing Around:** Uses `docker compose up -d` (or the Podman equivalent) to update cleanly.
* **Safety First:** Makes a backup of your config file before making changes.
* **Easy to Understand:** Gives you clear error messages if something goes wrong.
* **One Simple File:** All you need is a single executable file.
* **Container Friendly:** Designed to run great in a container.
## Before You Get Started
* **Docker or Podman:** Make sure you've got one of these installed on all your servers.
* **SSH Keys - Gotta Have 'Em:** You *need* to set up passwordless SSH access from the machine running this service to all your other servers. No passwords allowed!
* **`which` Command:** Make sure the `which` command is installed.
* **Container Setup (If You're Going That Route):** If you're using the container, you'll need Docker or Podman on the *host* machine as well.
## Jump Right In (Containerized - Easiest!)
1. **Grab the Image:**
```bash
docker pull registry.gitlab.com/tentypekmatus/synchronizer/synchronizer:latest
```
2. **Set Up Your Container:**
Here's a basic `docker-compose.yml` to get you started:
```yaml
---
services:
synchronizer:
image: registry.gitlab.com/tentypekmatus/synchronizer/synchronizer:latest
volumes:
- ~/.ssh:/root/.ssh:ro # Wherever your ssh keys are.
- ~/.synchronizer.yml:/root/.synchronizer.yml:ro # Or somewhere else
networks:
- synchronizer_net
restart: unless-stopped
networks:
synchronizer_net:
driver: bridge
```
3. **Fire It Up:**
```bash
docker compose up -d
```
## Making It Your Own (Configuration: `synchronizer.yml`)
This service looks for a file called `.synchronizer.yml`. Inside a container, it expects to find it at the home directory of a container. If you're running it directly on your machine, it'll look in your home directory (`~/.synchronizer.yml`).
The first time you run it, it'll create a blank `synchronizer.yml` file for you if one doesn't exist. Then, you need to fill in the details:
```yaml
hosts:
- ["user", "192.168.1.10"] # Your "main" server
- ["user", "192.168.1.11"] # Another server
backend: Docker # Or use Podman
file: "/path/to/your/docker-compose.yml" # Optional: Defaults to ~/docker-compose.yml
```
* **`hosts`:** A list of server details: `["username", "IP address"]`. The *first* one in the list is the "main" server that it watches for changes.
* **`backend`:** Tell it whether you're using `Docker` or `Podman`.
* **`file`:** Where your `docker-compose.yml` (or similar) is located. If you don't specify, it'll assume it's in your home directory.
## Keeping It Running
Since we're recommending the container route, just manage the container itself using Docker Compose or similar tools. Make sure it restarts automatically if it crashes. That's it!