Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Semaphore Ansible UI: Home Server Setup Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Semaphore is a web-based UI for running Ansible playbooks, making it easier to manage automation from any device on your network. This guide walks you through installing Semaphore on a Linux home server, connecting it to a Git repository, and running your first playbook. You'll need a Linux server (Ubuntu/Debbian used here), a Git repository with your playbooks, and basic command-line comfort.

What You'll Need

  • A Linux home server (Ubuntu 20.04/22.04/24.04 or Debian 11/12) with a user that has sudo privileges
  • Git installed on the server (sudo apt install git)
  • A Git repository (GitHub, GitLab, or self-hosted) containing your Ansible playbooks
  • A domain or IP address to access the web UI (localhost works for testing)
  • Port 3000 open on your firewall if you want remote access (optional)

Step-by-Step

  1. Update your system
    Run sudo apt update && sudo apt upgrade -y to ensure your server is current.
  2. Install dependencies
    Semaphore needs a database and a web server. Install PostgreSQL and Nginx (optional but recommended for TLS):
    sudo apt install postgresql nginx -y
  3. Create a database and user
    Switch to the postgres user and create a database for Semaphore:
    sudo -u postgres psql
    Then run:
    CREATE DATABASE semaphore;
    CREATE USER semaphore WITH PASSWORD 'your_strong_password';
    GRANT ALL PRIVILEGES ON DATABASE semaphore TO semaphore;
    Exit with \q.
  4. Download Semaphore
    Go to the official Semaphore releases page on GitHub and grab the latest Linux amd64 .deb package. For example:
    wget https://github.com/semaphoreui/semaphore/releases/download/v2.8.90/semaphore_2.8.90_linux_amd64.deb
    Replace the version with the latest one. Install it with sudo dpkg -i semaphore_*.deb.
  5. Create a config file
    Semaphore uses a configuration file. Create one at /etc/semaphore/config.json with:
    {
      "postgres": "host=127.0.0.1 user=semaphore password=your_strong_password dbname=semaphore sslmode=disable",
      "tmp_path": "/tmp/semaphore",
      "web_host": "0.0.0.0",
      "web_port": "3000",
      "cookie_hash": "random_string_here",
      "cookie_encryption": "another_random_string",
      "access_key_encryption": "third_random_string"
    }

    Generate the random strings using openssl rand -hex 32 three times. Adjust the database password to match yours.
  6. Set up the systemd service
    Semaphore ships with a systemd unit. Enable and start it:
    sudo systemctl enable semaphore
    sudo systemctl start semaphore
    Check status with sudo systemctl status semaphore.
  7. Access the web UI
    Open your browser to http://your-server-ip:3000. You'll see a setup screen. Fill in your admin username, email, and password. Leave the database fields as they are (they should be pre-filled from the config). Click Create.
  8. Add your Git repository
    After logging in, go to Repositories in the left menu. Click New Repository. Enter a name, the Git URL (e.g., https://github.com/yourname/ansible-playbooks.git), and if private, provide an access token or SSH key. Test the connection and save.
  9. Add an environment
    Go to Environments and create one. Select your repository, choose the branch (e.g., main), and set the playbook path (e.g., playbooks/site.yml). You can also set inventory variables here.
  10. Create a project
    Go to Projects and create a new project. Name it, then add your environment to it. You'll also need to add a key (SSH key or password) for connecting to your target hosts. Do this under Keys in the project's settings.
  11. Run your first playbook
    Inside the project, go to Job Templates and create one. Select your environment, choose a playbook file, and set the inventory (static or dynamic). Save, then click Run to execute. Watch the live output in the browser.

Common Mistakes

  • Wrong database credentials – Semaphore will fail to start if the password in config.json doesn't match the PostgreSQL user. Double-check the password and that the database exists.
  • Forgetting to open the firewall – If you can't access the UI from another device, ensure port 3000 is allowed in your firewall (e.g., sudo ufw allow 3000).
  • Using a private repo without credentials – Semaphore can't clone a private repository without an access token or SSH key. Make sure you add them in the repository settings.
  • Incorrect playbook path – The playbook path is relative to the repository root. If your playbook is in playbooks/site.yml, enter exactly that, not /playbooks/site.yml.
  • Not setting the cookie secrets – Using the same placeholder strings for cookie_hash, cookie_encryption, and access_key_encryption will cause session errors. Generate unique random strings for each.

Tips

  • Use a dedicated Linux user for Semaphore instead of root. Create one with sudo useradd -r -s /bin/false semaphore and assign ownership of the config file to it.
  • Set up Nginx as a reverse proxy to enable HTTPS. Create an Nginx site config that proxies to localhost:3000 and use Let's Encrypt for a free SSL certificate.
  • Store your Ansible vault passwords in Semaphore's key store (under Keys) rather than in plain text in playbooks.
  • Schedule jobs using cron or Semaphore's built-in schedule feature (available in the job template settings) to run playbooks automatically.
  • Back up the Semaphore database regularly. Use pg_dump semaphore > backup.sql to export it.

Troubleshooting

If Semaphore doesn't start or the UI isn't reachable, try these in order:

  1. Check the service status – Run sudo systemctl status semaphore to see if it's running. If it's failed, view logs with sudo journalctl -u semaphore -n 50.
  2. Verify the database connection – Test with psql -h 127.0.0.1 -U semaphore -d semaphore and enter your password. If that fails, re-run the PostgreSQL setup steps.
  3. Check the config file syntax – Run semaphore -config /etc/semaphore/config.json as root to see any parsing errors. Ensure the JSON is valid (no trailing commas).
  4. Restart after changes – After editing config.json, restart with sudo systemctl restart semaphore.
  5. If the UI loads but login fails – The admin user might not have been created. Go to the setup screen again (the first visit) and create it. If you already created it, try resetting the password by deleting the user from the database and re-running setup.
  6. If cloning fails – Test the Git URL manually on the server using git clone with the same credentials. Check that the access token has read access to the repo.

Frequently Asked Questions

Can I use SQLite instead of PostgreSQL?

Yes, Semaphore supports SQLite, but PostgreSQL is recommended for production. To use SQLite, change the config to "sqlite": "/var/lib/semaphore/semaphore.db" and remove the postgres line. However, SQLite may have concurrency limitations.

How do I update Semaphore to a newer version?

Download the new .deb package and run sudo dpkg -i semaphore_new.deb. Your config and database remain intact. Restart the service afterwards.

Can I run Semaphore in Docker?

Yes, official Docker images are available. Use docker run -p 3000:3000 semaphoreui/semaphore:latest and provide environment variables for the database. This is often simpler for testing.

How do I add an SSH key for connecting to my target hosts?

In your project, go to Keys and create a new key of type SSH Key. Paste the private key content. Then in the job template, select that key under SSH Key.

Is Semaphore free to use?

Yes, Semaphore is open-source (MIT license) and free. There is no paid tier.

Can I run multiple projects with different repositories?

Yes, each project can have its own environments and repositories. Create a new project and add the appropriate environments.