Welcome to our guide on how to install Semaphore Ansible Web UI on Ubuntu / Debian. Semaphore is an open source alternative to Ansible Tower. It allows you to launch and manage Ansible Tasks from a Web interface.

Semaphore has the following dependencies:

  • MySQL >= 5.6.4/MariaDB >= 5.3
  • ansible
  • git >= 2.x

We will consider the installation of Semaphore on both Debian & Ubuntu line of Distributions.

For CentOS 7, use: How to Install Semaphore Ansible Web UI on CentOS 7

How to Install Semaphore on Ubuntu / Debian

Here are the steps you need to follow to have Semaphore installed on Ubuntu / Debian system.

Step 1: Update system and install git

Start work from an updated system with git installed.

sudo apt-get update
sudo apt-get -y install git curl wget

Confirm that Git version installed is = 2.x.

# Ubuntu 18.04
$ git --version
git version 2.17.1

# Debian 9
$ git --version
git version 2.11.0

Step 2: Install Ansible

Add Ansible PPA repository and install Ansible.

For Ubuntu

sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible -y

If you get error like “apt-add-repository: command not found“, then check install add-apt-repository on Debian/Ubuntu.

For Debian

echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/ansible.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
sudo apt update
sudo apt-get install ansible -y

Confirm Ansible version installed.

$ ansible --version
ansible 2.7.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]

Step 3: Install MariaDB/MySQL Database server

You can choose MySQL or MariaDB database server. We will do MariaDB in this tutorial.

sudo apt-get -y install mariadb-server

Set root password when prompted.

Step 4: Download Semaphore

Visit the Semaphore Releases page and copy the download link for your OS.

wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.5.1/semaphore_2.5.1_linux_amd64.deb

Install the Debian package downloaded.

$ sudo dpkg -i semaphore_2.5.1_linux_amd64.deb
Selecting previously unselected package semaphore.
(Reading database … 38297 files and directories currently installed.)
Preparing to unpack semaphore_2.5.1_linux_amd64.deb …
Unpacking semaphore (2.5.1) …
Setting up semaphore (2.5.1) …

Check if you have semaphore binary in your $PATH.

$ which semaphore
/usr/bin/semaphore

$ semaphore -version
v2.5.1

Step 4: Setup Semaphore

Run the following command to start Semaphore setup in your system.

# semaphore -setup
Hello! You will now be guided through a setup to:
Set up configuration for a MySQL/MariaDB database
Set up a path for your playbooks (auto-created)
Run database Migrations
Set up initial semaphore user & password
DB Hostname (default 127.0.0.1:3306): 127.0.0.1:3306
DB User (default root): root
DB Password: <root Password>
DB Name (default semaphore): semaphore
Playbook path (default /tmp/semaphore): /opt/semaphore
Web root URL (optional, example http://localhost:8010/): http://localhost:8010/
Enable email alerts (y/n, default n): n
Enable telegram alerts (y/n, default n): n
Enable LDAP authentication (y/n, default n): n

If you choose to turn on email/telegram alerts or LDAP authentication, set appropriate values.

Confirm generated configuration and Agree to start installation.

Generated configuration:
{
"mysql": {
"host": "127.0.0.1:3306",
"user": "root",
"pass": "password",
"name": "semaphore"
},
"port": "",
"tmp_path": "/opt/semaphore",
"cookie_hash": "0Jpz8DrxGg02+Bx7P3lDPa+Tdu0nOEw6HwKMu22Oo60=",
"cookie_encryption": "I3hI3Fgitr5OMOOWmnaR59hxLUP6FlnAPdL/WJbSlO0=",
"email_sender": "",
"email_host": "",
"email_port": "",
"web_host": "http://localhost:8010/",
"ldap_binddn": "",
"ldap_bindpassword": "",
"ldap_server": "",
"ldap_searchdn": "",
"ldap_searchfilter": "",
"ldap_mappings": {
"dn": "",
"mail": "",
"uid": "",
"cn": ""
},
"telegram_chat": "",
"telegram_token": "",
"concurrency_mode": "",
"max_parallel_tasks": 0,
"email_alert": false,
"telegram_alert": false,
"ldap_enable": false,
"ldap_needtls": false
}

Confirm these values are correct to initiate setup.

 Is this correct? (yes/no): yes
Config output directory (default /root):
WARN[0037] An input error occured:unexpected newline
Running: mkdir -p /root..
Configuration written to /root/config.json..
Pinging db..
Running DB Migrations..
Checking DB migrations
Creating migrations table
......
Migrations Finished

Set username

Username: computingforgeeks
Email: [email protected]
WARN[0268] sql: no rows in result set level=Warn
Your name: computingforgeeks
Password: StrongPassword
You are all setup computingforgeeks!
Re-launch this program pointing to the configuration file
./semaphore -config /root/config.json

To run as daemon:
nohup ./semaphore -config /root/config.json &
You can login with c[email protected] or computingforgeeks.

You can set other configuration values on the file /root/config.json.

Step 5: Start Semaphore Service

Now that we have completed setup of Semaphore, let’s start it.

semaphore -config /root/config.json &

Step 6: Configure Systemd

Let’s now configure Semaphore Ansible UI to be managed by systemd.

Create systemd service unit file.

sudo vim /etc/systemd/system/semaphore.service

The add:

[Unit]
Description=Semaphore Ansible UI
Documentation=https://github.com/ansible-semaphore/semaphore
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/semaphore -config /etc/semaphore/config.json
SyslogIdentifier=semaphore
Restart=always

[Install]
WantedBy=multi-user.target

Create Semaphore configurations directory:

sudo mkdir /etc/semaphore

Copy your configuration file to created directory:

sudo ln -s /root/config.json /etc/semaphore/config.json

Stop running instances of Semaphore.

sudo pkill semaphore

Confirm:

ps aux | grep sema

Reload systemd and start semaphore service.

sudo systemctl daemon-reload
sudo systemctl start semaphore

Check status to see if running:

$ systemctl status semaphore 
● semaphore.service - Semaphore Ansible UI
Loaded: loaded (/etc/systemd/system/semaphore.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2019-04-04 22:49:24 CEST; 31s ago
Docs: https://github.com/ansible-semaphore/semaphore
Main PID: 9779 (semaphore)
CGroup: /system.slice/semaphore.service
└─9779 /usr/bin/semaphore -config /etc/semaphore/config.json
Apr 04 22:49:24 mydebian systemd[1]: Started Semaphore Ansible UI.
Apr 04 22:49:24 mydebian semaphore[9779]: Using config file: /etc/semaphore/config.json
Apr 04 22:49:24 mydebian semaphore[9779]: Semaphore v2.5.1
Apr 04 22:49:24 mydebian semaphore[9779]: Port :3000
Apr 04 22:49:24 mydebian semaphore[9779]: MySQL [email protected]:3306 semaphore
Apr 04 22:49:24 mydebian semaphore[9779]: Tmp Path (projects home) /opt/semaphore
Apr 04 22:49:24 mydebian semaphore[9779]: Checking DB migrations

Set Service to start at boot.

$ sudo systemctl enable semaphore
Created symlink /etc/systemd/system/multi-user.target.wants/semaphore.service → /etc/systemd/system/semaphore.service.

Port 3000 should now be Open

# ss -tunelp | grep 3000
tcp LISTEN 0 128 :::3000 :::* users:(("semaphore",pid=9779,fd=3)) uid:999 ino:45866 sk:6 v6only:0 <->

Step 7: Setup Nginx Proxy (Optional)

To be able to access Semaphore Web interface with a domain name, use the guide below to setup.

How to Configure Nginx Proxy for Semaphore Ansible Web UI

Step 8: Access Semaphore Web interface

On your web browser, open semaphore Server IP on port 3000.

Use the username/email created earlier during installation to Sign in. Web console for semaphore should be shown after authentication.

You’re ready to manage your servers with Ansible and powerful Web UI.

The initial steps required are:

  • Add SSH keys / API keys used by Ansible – Under Key Store > create key
  • Create Inventory file with servers to manage – Under Inventory > create inventory
  • Create users and add to Team(s)
  • Create Environments
  • Add Playbook repositories
  • Create Task Templates and execute

Also check a comprehensive guide on semaphore Web UI. Also check:

Install Ansible AWX on CentOS 7 / Fedora with Nginx Reverse Proxy and Letsencrypt

Install Ansible AWX on Debian

Install Ansible AWX Ubuntu