CentOS7 に Ansible UI である semaphore をインストールする
ANSIBLE TOWER は Ansible にアクセスする WebUI を提供してくれます。これとよく似た OSS である semaphore のインストール方法をメモしておきます。今回は CentOS7 にインストールしました。
DB のインストール
semaphore をインストールする前に MariaDB をインストールしておきます。
| sudo yum -y install epel-release
sudo yum -y install ansible mariadb mariadb-server
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
sudo mysql_secure_installation
|
ユーザとデータベースを作成しておきます。
| mysql -u root
CREATE DATABASE semaphore;
CREATE USER 'semaphore'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON semaphore.* TO 'semaphore'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
|
semaphore のインストール
semaphore のバイナリをダウンロードし、インストールします。
| wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.0.4/semaphore_linux_amd64
sudo mv semaphore_linux_amd64 /usr/bin/semaphore
sudo chmod a+x /usr/bin/semaphore
sudo mkdir /opt/semaphore
sudo semaphore -setup
|
semaphore -setup を起動すると以下のように対話的なセットアップが開始されます。
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 | $ sudo semaphore -setup
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 seamphore user & password
> DB Hostname (default 127.0.0.1:3306):
> DB User (default root): semaphore
> DB Password: PASSWORD
> DB Name (default semaphore): semaphore
> Playbook path: /opt/semaphore
Generated configuration:
{
"mysql": {
"host": "127.0.0.1:3306",
"user": "semaphore",
"pass": "PASSWORD",
"name": "semaphore"
},
"port": "",
"bugsnag_key": "",
"tmp_path": "/opt/semaphore",
"cookie_hash": "IY6mfnNcw41gMfZGTo0GiWCW1lvamKfgnisGMZJYeGM=",
"cookie_encryption": "Jo1rrtZEiNm6P/mZXNRCGo6mn5tWEVO+o5z307Czu4U="
}
> Is this correct? (yes/no): yes
Running: mkdir -p /opt/semaphore..
Configuration written to /opt/semaphore/semaphore_config.json..
Pinging database..
Running DB Migrations..
Creating migrations table
Executing migration v0.0.0 (at 2016-10-22 11:39:38.083956784 +0900 JST)...
[11/11]
Executing migration v1.0.0 (at 2016-10-22 11:39:38.433961732 +0900 JST)...
[7/7]
Executing migration v1.1.0 (at 2016-10-22 11:39:38.800987107 +0900 JST)...
[1/1]
Executing migration v1.2.0 (at 2016-10-22 11:39:38.860046834 +0900 JST)...
[1/1]
Executing migration v1.3.0 (at 2016-10-22 11:39:38.883044699 +0900 JST)...
[3/3]
Executing migration v1.4.0 (at 2016-10-22 11:39:39.048971905 +0900 JST)...
[2/2]
Executing migration v1.5.0 (at 2016-10-22 11:39:39.184130928 +0900 JST)...
[1/1]
Executing migration v0.1.0 (at 2016-10-22 11:39:39.208801409 +0900 JST)...
[6/6]
Executing migration v1.6.0 (at 2016-10-22 11:39:39.377407117 +0900 JST)...
[4/4]
Executing migration v1.7.0 (at 2016-10-22 11:39:39.59797107 +0900 JST)...
[1/1]
> Username: semaphore
> Email:
> Your name: semaphore
> Password: PASSWORD
You are all setup semaphore!
Re-launch this program pointing to the configuration file
./semaphore -config /opt/semaphore/semaphore_config.json
To run as daemon:
nohup ./semaphore -config /opt/semaphore/semaphore_config.json &
You can login with or semaphore.
|
systemd に登録する
systemd に登録するには以下のファイルを作成します。
- /etc/systemd/system/semaphore.service
- /etc/default/semaphore
/etc/systemd/system/semaphore.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | [Unit]
Description=Ansible Semaphore
After=syslog.service
Requires=network.target
[Service]
Type=forking
EnvironmentFile=-/etc/default/semaphore
ExecStart=/bin/sh -c "/usr/bin/semaphore -config ${SEMAPHORE_CONFIG} >> ${SEMAPHORE_LOGS} 2>&1 &"
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
|
/etc/default/semaphore
| SEMAPHORE_CONFIG=/opt/semaphore/semaphore_config.json
SEMAPHORE_LOGS=/var/log/semaphore.log
|