97

How To Install Semaphore Ansible Web UI on CentOS 7

 2 years ago
source link: https://computingforgeeks.com/how-to-install-semaphore-ansible-web-ui-on-centos-7/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

In this guide, we will install Semaphore Ansible Web UI on CentOS 7. Semaphore is an open source web-based solution that makes Ansible easy to use for IT teams of all kinds. It gives you a Web interface from where you can launch and manage Ansible Tasks.

Semaphore installation on CentOS 7

Semaphore depends on the following tools:

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

We will start the installation by ensuring these dependencies are installed on your CentOS 7 server. So follow steps in the next sections to ensure all is set.

Step 1: Install MariaDB Database Server

We have a comprehensive guide on installation of MariaDB on CentOS 7. The link is shared below.

Install MariaDB 10.x on CentOS 7

Take note of the root password configured for the database server.

Step 2: Install git 2.x

Install git 2.x on your CentOS 7 server using our guide below.

How to Install latest version of Git ( Git 2.x ) on CentOS 7

Confirm git version.

$ git --version
git version 2.16.5

Step 3: Install Ansible

Install Ansible on your CentOS 7 server.

sudo yum -y install epel-release
sudo yum -y install ansible

Test if ansible command is available.

$ 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/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

Step 4: Download Semaphore

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

sudo yum -y install wget
wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.5.1/semaphore_2.5.1_linux_amd64.rpm

Install Semaphore package:

$ sudo rpm -Uvh semaphore_2.5.1_linux_amd64.rpm
Preparing… ################################# [100%]
Updating / installing…
1:semaphore-2.5.1-1 ################################# [100%]

Check if you have semaphore binary in your $PATH.

$ which semaphore
/usr/bin/semaphore

$ semaphore -version
v2.5.1

Step 5: 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

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 6: Configure Systemd

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

Create systemd service unit file.

sudo vi /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 or server name.

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 detailed guide on semaphore Web UI.

For Ubuntu / Debian installation, check:

How to Setup Semaphore Ansible Web UI on Ubuntu / Debian

You can also give AWX a shot:

Install Ansible AWX on CentOS 7 / Fedora

Install Ansible AWX on Debian

Install Ansible AWX Ubuntu


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK