【Raspberry Pi】semaphore を導入してみる【Ansible】

ラズパイのリソースが余っていたので、semaphore を導入して遊んでみようと思います。
※ 事前に下記を導入する必要ありです。
・MySQL >= 5.6.4/MariaDB >= 5.3
・git >= 2.x

## epel レポジトリ追加
cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0
EOF

## Ansible の導入
yum install ansible

## ソースの取得&初期設定
mkdir /usr/local/semaphore
mkdir /opt/semaphore
cd /usr/local/src
wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.5.1/semaphore_2.5.1_linux_armv6.tar.gz
tar zxf semaphore_2.5.1_linux_armv6.tar.gz
./semaphore -setup   

## 実行ログ
[root@sanuki-raspi-nas01 src]# ./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 semaphore user & password

 > DB Hostname (default 127.0.0.1:3306): 127.0.0.1:3306
 > DB User (default root): root
 > DB Password: sanuki
 > 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

 Generated configuration:
 {
        "mysql": {
                "host": "127.0.0.1:3306",
                "user": "root",
                "pass": "sanuki",
                "name": "semaphore"
        },
        "port": "",
        "tmp_path": "/opt/semaphore",
        "cookie_hash": "k2uoMRgkbFL/UDQvaPZsMcLbqWSJIPafcgYtjWFjTg8=",
        "cookie_encryption": "hDysRlIpGNxW7PFKVImtmi4Pi5Qqg6GmxLhU03X+mVM=",
        "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
 }

 > Is this correct? (yes/no): yes
 > Config output directory (default /usr/local/src): /usr/local/semaphore
 Running: mkdir -p /usr/local/semaphore..
 Configuration written to /usr/local/semaphore/config.json..
 Pinging db..

 Running DB Migrations..
Checking DB migrations
Creating migrations table
Executing migration v0.0.0 (at 2020-09-18 02:17:34.184823983 +0900 JST m=+81.438963933)...
 [11/11]
Executing migration v1.0.0 (at 2020-09-18 02:17:35.823845162 +0900 JST m=+83.077984871)...
 [7/7]
Executing migration v1.1.0 (at 2020-09-18 02:17:36.679280042 +0900 JST m=+83.933420011)...
 [1/1]
Executing migration v1.2.0 (at 2020-09-18 02:17:36.767607043 +0900 JST m=+84.021746974)...
 [1/1]
Executing migration v1.3.0 (at 2020-09-18 02:17:36.881818644 +0900 JST m=+84.135958038)...
 [3/3]
Executing migration v1.4.0 (at 2020-09-18 02:17:37.020016932 +0900 JST m=+84.274156808)...
 [2/2]
Executing migration v1.5.0 (at 2020-09-18 02:17:37.106031563 +0900 JST m=+84.360171253)...
 [1/1]
Executing migration v0.1.0 (at 2020-09-18 02:17:37.144696735 +0900 JST m=+84.398836537)...
 [6/6]
Executing migration v1.6.0 (at 2020-09-18 02:17:37.258300328 +0900 JST m=+84.512440000)...
 [4/4]
Executing migration v1.7.0 (at 2020-09-18 02:17:37.444168013 +0900 JST m=+84.698307797)...

   [Unit]
 [1/1]
Executing migration v1.8.0 (at 2020-09-18 02:17:37.487883012 +0900 JST m=+84.742022795)...
 [2/2]
Executing migration v1.9.0 (at 2020-09-18 02:17:37.535266506 +0900 JST m=+84.789406326)...
 [2/2]
Executing migration v2.2.1 (at 2020-09-18 02:17:37.595956582 +0900 JST m=+84.850096384)...
 [2/2]
Executing migration v2.3.0 (at 2020-09-18 02:17:37.687595511 +0900 JST m=+84.941735239)...
 [3/3]
Executing migration v2.3.1 (at 2020-09-18 02:17:37.820249981 +0900 JST m=+85.074389802)...
 [1/1]
Executing migration v2.3.2 (at 2020-09-18 02:17:37.870296322 +0900 JST m=+85.124436179)...
 [1/1]
Executing migration v2.4.0 (at 2020-09-18 02:17:37.914739049 +0900 JST m=+85.168878703)...
 [1/1]
Executing migration v2.5.0 (at 2020-09-18 02:17:37.95180208 +0900 JST m=+85.205941919)...
 [1/1]
Migrations Finished


 > Username: sanuki
 > Email: xxxxxxxxxxxxxxx
 > Your name: sanuki
 > Password: sanuki

 You are all setup sanuki!
 Re-launch this program pointing to the configuration file

./semaphore -config /usr/local/semaphore/config.json

 To run as daemon:

nohup ./semaphore -config /usr/local/semaphore/config.json &

 You can login with n41210guitar@gmail.com or sanuki.
 
 
## 起動ファイル作成
mv /usr/local/src/semaphore /usr/local/bin/
vi /usr/lib/systemd/system/semaphore.service
=============================================================================
[Unit]
Description=semaphore
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/semaphore -config /usr/local/semaphore/config.json
ExecStop=/usr/bin/pkill semaphore
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
=============================================================================

## サービス起動
systemctl daemon-reload
systemctl start semaphore
systemctl enable semaphore

3000 ポートで listen するので http://localhost:3000 で接続ですね。

投稿者: snk

保有資格 ・TOEIC 835 ・LPIC 304 ・AWS SAA/SAP ・GCP PCA ・IPA SC

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です