Why Semaphore?
Running Ansible from the terminal works, but Semaphore adds:
- Visual dashboard — See all playbook runs, their status, and logs.
- One-click execution — No need to SSH into a server and type commands.
- Scheduling — Cron-like scheduling for recurring playbooks.
- RBAC — Give team members access without sharing SSH keys.
- Audit trail — Full execution history with timestamps and output.
Prerequisites
- Docker or a Go binary + database (PostgreSQL/MySQL/SQLite).
- An existing Ansible playbook in a Git repository.
- SSH access from the Semaphore server to managed hosts.
Step 1: Deploy with Docker Compose
# docker-compose.yml
version: "3"
services:
semaphore:
image: semaphoreui/semaphore:latest
container_name: semaphore
environment:
SEMAPHORE_DB_DIALECT: bolt
SEMAPHORE_ADMIN_PASSWORD: admin123
SEMAPHORE_ADMIN_NAME: admin
SEMAPHORE_ADMIN_EMAIL: admin@example.com
SEMAPHORE_ADMIN: admin
ports:
- "3000:3000"
volumes:
- ./semaphore-data:/etc/semaphore
restart: always
docker compose up -d
Access at http://your-server:3000. Log in with the admin credentials.
Step 2: Configure Key Store
- Go to Key Store → New Key.
- Add your SSH private key (for connecting to managed hosts).
- Add any sudo/become passwords as “Login with password” type keys.
- These credentials are stored encrypted and referenced by task templates.
Step 3: Add a Git Repository
- Go to Repositories → New Repository.
- Name: e.g., “Infrastructure Playbooks”
- URL:
git@github.com:your-org/ansible-playbooks.git - Branch:
main - SSH Key: Select the key from your Key Store.
Step 4: Create an Inventory
- Go to Inventory → New Inventory.
- Choose Static or File (from the Git repo).
- For Static, paste your inventory in INI or YAML format:
[webservers]
web1.example.com
web2.example.com
[databases]
db1.example.com
Step 5: Create and Run a Task Template
- Go to Task Templates → New Template.
- Playbook Filename:
site.yml(path relative to the repository root). - Repository: Select your repository.
- Inventory: Select your inventory.
- Environment: Add any extra variables (JSON format).
- Schedule: (Optional) Set a cron expression for automatic runs.
- Click Run to execute immediately.
Troubleshooting
| Problem | Solution |
|---|---|
| Playbook fails but works from CLI | Add SSH keys and sudo passwords in Key Store; check environment variables |
| ”Repository not accessible” | Verify Git URL and SSH key; test git clone manually from the Semaphore server |
| Task stuck in “waiting” | Check that the Semaphore worker is running; restart the container |
| Permission denied on managed hosts | Ensure the SSH key in Key Store matches the authorized_keys on target hosts |
| Schedule not triggering | Verify cron expression syntax; check Semaphore logs for scheduler errors |
Summary
- Semaphore is a lightweight AWX alternative — single binary, 256 MB RAM.
- Use the Key Store for SSH keys and passwords.
- Schedule playbooks with cron expressions for automated infrastructure management.
- Check execution logs in the Semaphore UI for debugging failed runs.