Ansible Semaphore is a modern UI for Ansible. It lets you easily run Ansible playbooks, get notifications about fails, control access to deployment system. If your project has grown and deploying from the terminal is no longer for you then Ansible Semaphore is what you need.
Install some dependencies
1
| sudo apt install git curl wget python3-passlib software-properties-common -y
|
Install the Ansible Repository
1
2
3
| sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible -y
|
Install MariaDB
1
2
| curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s --
sudo apt install mariadb-server mariadb-client -y
|
Secure the Database
1
| sudo mariadb-secure-installation
|
1
2
3
4
5
6
| Switch to unix_socket authentication [Y/n] n enter
Change the root password? [Y/n] enter
Remove anonymous users? [Y/n] enter
Disallow root login remotely? [Y/n] enter
Remove test database and access to it? [Y/n] enter
Reload privilege tables now? [Y/n] enter
|
Create Sempahore Database
1
2
3
4
5
| sudo mariadb
CREATE DATABASE semaphore;
GRANT ALL PRIVILEGES ON semaphore.* TO semaphore@localhost IDENTIFIED BY 'randomly_generated_password_here';
exit;
|
Install Semaphore
Find latest version of Semaphore:
https://github.com/semaphoreui/semaphore
Go to latest release and find the semaphore_x.x.xxx_linux_amd64.deb file and right click it and “Copy link address”.
1
| wget https://github.com/semaphoreui/semaphore/releases/download/v2.9.112/semaphore_2.9.112_linux_amd64.deb
|
1
| sudo apt install ./semaphore_2.9.112_linux_amd64.deb
|
NOTE: If you get the following error: N: Download is performed unsandboxed as root as file ‘/home/sysadmin/semaphore_2.9.112_linux_amd64.deb’ couldn’t be accessed by user ‘_apt’. - pkgAcquire::Run (13: Permission denied) - This is a known bug, it can be ignored.
Setup Semaphore to acquire config.json file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| Hello! You will now be guided through a setup to:
1. Set up configuration for a MySQL/MariaDB database
2. Set up a path for your playbooks (auto-created)
3. Run database Migrations
4. Set up initial semaphore user & password
What database to use:
1 - MySQL
2 - BoltDB
3 - PostgreSQL
(default 1): 1
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://server_ip:3000/
Enable email alerts (y/n, default n): n
Enable telegram alerts (y/n, default n): n
Enable slack alerts? (yes/no) (default no): n
Enable LDAP authentication (y/n, default n): n
Config output directory (default /home/user): enter
Running: mkdir -p /home/user..
Configuration written to /home/user/config.json..
Pinging db..
Running db Migrations..
Executing migration v0.0.0 (at 2023-09-19 04:34:51.911307307 +0000 UTC m=+79.883776533)...
Creating migrations table
[12/0]8]
Executing migration v1.0.0 (at 2023-09-19 04:34:52.119025252 +0000 UTC m=+80.091494471)...
[4/87]
Executing migration v1.2.0 (at 2023-09-19 04:34:52.203560681 +0000 UTC m=+80.176029900)...
[2/0]6]
Executing migration v1.3.0 (at 2023-09-19 04:34:52.219692693 +0000 UTC m=+80.192161906)...
[4/0]]
Executing migration v1.4.0 (at 2023-09-19 04:34:52.278187426 +0000 UTC m=+80.250656642)...
[5/0]]]
Executing migration v1.5.0 (at 2023-09-19 04:34:52.334484623 +0000 UTC m=+80.306953843)...
[4/0]]]
Executing migration v1.6.0 (at 2023-09-19 04:34:52.383798165 +0000 UTC m=+80.356267389)...
[5/0]]
Executing migration v1.7.0 (at 2023-09-19 04:34:52.446619294 +0000 UTC m=+80.419088514)...
[2/0]]
Executing migration v1.8.0 (at 2023-09-19 04:34:52.462620493 +0000 UTC m=+80.435089708)...
[2/0]]
Executing migration v1.9.0 (at 2023-09-19 04:34:52.478200538 +0000 UTC m=+80.450669751)...
[2/0]]
Executing migration v2.2.1 (at 2023-09-19 04:34:52.494793998 +0000 UTC m=+80.467263215)...
[5/0]]]
Executing migration v2.3.0 (at 2023-09-19 04:34:52.5307822 +0000 UTC m=+80.503251416)...
[4/0]]
Executing migration v2.3.1 (at 2023-09-19 04:34:52.576908569 +0000 UTC m=+80.549377793)...
[7/0]]]
Executing migration v2.3.2 (at 2023-09-19 04:34:52.651785072 +0000 UTC m=+80.624254290)...
[6/0]]]
Executing migration v2.4.0 (at 2023-09-19 04:34:52.687043776 +0000 UTC m=+80.659512990)...
[2/0]]
Executing migration v2.5.0 (at 2023-09-19 04:34:52.703395937 +0000 UTC m=+80.675865158)...
[2/0]]
Executing migration v2.5.2 (at 2023-09-19 04:34:52.719182941 +0000 UTC m=+80.691652158)...
[2/0]]
Executing migration v2.7.1 (at 2023-09-19 04:34:52.734913235 +0000 UTC m=+80.707382445)...
[2/0]]
Executing migration v2.7.4 (at 2023-09-19 04:34:52.767540559 +0000 UTC m=+80.740009770)...
[2/0]]
Executing migration v2.7.6 (at 2023-09-19 04:34:52.795717782 +0000 UTC m=+80.768187004)...
[2/0]6]
Executing migration v2.7.8 (at 2023-09-19 04:34:52.799543428 +0000 UTC m=+80.772012639)...
[4/57]
Executing migration v2.7.9 (at 2023-09-19 04:34:52.866607688 +0000 UTC m=+80.839076913)...
[2/77]
Executing migration v2.7.10 (at 2023-09-19 04:34:52.899836789 +0000 UTC m=+80.872306011)...
[1/43]
Executing migration v2.7.12 (at 2023-09-19 04:34:52.919537033 +0000 UTC m=+80.892006244)...
[3/0]]
Executing migration v2.7.13 (at 2023-09-19 04:34:53.002538379 +0000 UTC m=+80.975007609)...
[3/0]2]
Executing migration v2.8.0 (at 2023-09-19 04:34:53.030246412 +0000 UTC m=+81.002715627)...
[8/0]]
Executing migration v2.8.1 (at 2023-09-19 04:34:53.174857687 +0000 UTC m=+81.147326906)...
[1/63]
Executing migration v2.8.7 (at 2023-09-19 04:34:53.218258925 +0000 UTC m=+81.190728145)...
[1/43]
Executing migration v2.8.8 (at 2023-09-19 04:34:53.239693078 +0000 UTC m=+81.212162299)...
[2/98]]
Executing migration v2.8.20 (at 2023-09-19 04:34:53.307433756 +0000 UTC m=+81.279902976)...
[3/0]9]
Executing migration v2.8.25 (at 2023-09-19 04:34:53.335322531 +0000 UTC m=+81.307791744)...
[5/0]]]
Executing migration v2.8.26 (at 2023-09-19 04:34:53.420930803 +0000 UTC m=+81.393400020)...
[2/0]]
Executing migration v2.8.36 (at 2023-09-19 04:34:53.437385567 +0000 UTC m=+81.409854780)...
[4/0]]
Executing migration v2.8.38 (at 2023-09-19 04:34:53.487262226 +0000 UTC m=+81.459731437)...
[9/0]]]
Executing migration v2.8.39 (at 2023-09-19 04:34:53.536066973 +0000 UTC m=+81.508536191)...
[8/0]]]
Executing migration v2.8.40 (at 2023-09-19 04:34:53.614897143 +0000 UTC m=+81.587366362)...
[7/0]]
Executing migration v2.8.42 (at 2023-09-19 04:34:53.750790978 +0000 UTC m=+81.723260199)...
[1/26]
Executing migration v2.8.51 (at 2023-09-19 04:34:53.766528154 +0000 UTC m=+81.738997380)...
[3/0]]
Executing migration v2.8.57 (at 2023-09-19 04:34:53.795245203 +0000 UTC m=+81.767714426)...
[3/0]]
Executing migration v2.8.58 (at 2023-09-19 04:34:53.827463915 +0000 UTC m=+81.799933140)...
[1/57]
Executing migration v2.8.91 (at 2023-09-19 04:34:53.843839765 +0000 UTC m=+81.816308987)...
[3/46]
Migrations Finished
> Username: admin
> Email: [email protected]
> Your name: Your Name
> Password: password
You are all setup <Your Name>!
Re-launch this program pointing to the configuration file
./semaphore server --config /home/user/config.json
|
Once complete, the config.json file will be in your home directory.
Create a directory in /etc for semaphore:
1
| sudo mkdir /etc/semaphore
|
Make the directory accessible by your user:
1
| sudo chown user:group /etc/semaphore
|
Move the config.json to that directory:
1
| sudo mv config.json /etc/semaphore
|
Run Semaphore as Daemon
Create Service File
1
| sudo nano /etc/systemd/system/semaphore.service
|
Copy Contents into File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [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 server --config /etc/semaphore/config.json
SyslogIdentifier=semaphore
Restart=always
[Install]
WantedBy=multi-user.target
|
Initiate the Service
1
2
| sudo systemctl daemon-reload
sudo systemctl start semaphore
|
Check Status
1
| systemctl status semaphore
|
1
2
3
4
5
6
7
8
9
10
| * semaphore.service - Semaphore Ansible UI
Loaded: loaded (/etc/systemd/system/semaphore.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-09-21 04:51:08 UTC; 9h ago
Docs: https://github.com/ansible-semaphore/semaphore
Main PID: 667 (semaphore)
Tasks: 6 (limit: 76963)
Memory: 47.7M
CPU: 23.769s
CGroup: /system.slice/semaphore.service
`-667 /usr/bin/semaphore server --config /etc/semaphore/config.json
|
Enable Service on Reboot
1
| sudo systemctl enable semaphore
|
Login to Semaphore in Your Browser
1
| http://your_server_ip:3000
|