====== 安裝 Ansible UI - Semaphore (Docker) ======
* 安裝環境 : 參考 - [[tech/alpine_docker]]
===== 安裝程序 =====
- 建立 docker-compose.yml
services:
postgres:
restart: unless-stopped
image: postgres:14
hostname: postgres
volumes:
- semaphore-postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: semaphore
POSTGRES_PASSWORD: semaphore
POSTGRES_DB: semaphore
semaphore:
restart: unless-stopped
ports:
- 3000:3000
image: semaphoreui/semaphore:latest
environment:
TZ: Asia/Taipei
SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: semaphore
SEMAPHORE_DB_HOST: postgres
SEMAPHORE_DB_PORT: 5432
SEMAPHORE_DB_DIALECT: postgres
SEMAPHORE_DB: semaphore
SEMAPHORE_PLAYBOOK_PATH: /tmp/semaphore/
SEMAPHORE_ADMIN_PASSWORD: changeme
SEMAPHORE_ADMIN_NAME: admin
SEMAPHORE_ADMIN_EMAIL: admin@localhost
SEMAPHORE_ADMIN: admin
SEMAPHORE_ACCESS_KEY_ENCRYPTION: gs72mPntFATGJs9qK0pQ0rKtfidlexiMjYCH9gWKhTU=
SEMAPHORE_LDAP_ACTIVATED: 'no' # if you wish to use ldap, set to: 'yes'
SEMAPHORE_LDAP_HOST: dc01.local.example.com
SEMAPHORE_LDAP_PORT: '636'
SEMAPHORE_LDAP_NEEDTLS: 'yes'
SEMAPHORE_LDAP_DN_BIND: 'uid=bind_user,cn=users,cn=accounts,dc=local,dc=shiftsystems,dc=net'
SEMAPHORE_LDAP_PASSWORD: 'ldap_bind_account_password'
SEMAPHORE_LDAP_DN_SEARCH: 'dc=local,dc=example,dc=com'
SEMAPHORE_LDAP_SEARCH_FILTER: "(\u0026(uid=%s)(memberOf=cn=ipausers,cn=groups,cn=accounts,dc=local,dc=example,dc=com))"
depends_on:
- postgres
volumes:
semaphore-postgres:
- 修改資料庫密碼相關項目 POSTGRES_PASSWORD 、 SEMAPHORE_DB_PASS
- 修改管理者相關項目 SEMAPHORE_ADMIN_PASSWORD 、 SEMAPHORE_ADMIN_EMAIL
- 修改存取密鑰項目 SEMAPHORE_ACCESS_KEY_ENCRYPTION 可使用以下語法產生
semaphore-44:~# head -c32 /dev/urandom | base64
EHLA/hOR6YQFrMhsXpfyApgKcT3/kvVxbQR/dGu0aD4=
- 啟動 docker compose docker compose up -d
- 使用 http://server_ip:3000 就可以看到登入畫面
===== 常見問題 =====
- 針對 ssh 第一次登入出現失敗問題解法
* 參考 - https://github.com/ansible-semaphore/semaphore/issues/675
* 可以在 Environment 內的 Extra variables 內加入
{"ansible_ssh_common_args":"'-o StrictHostKeyChecking=no'"}
* 或是在 inventory 設定時加上以下的段落
[all:vars]
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
:
- 針對無法 sudo 的議題 workaround 方式
* 參考 - https://github.com/ansible-semaphore/semaphore/issues/1518
* 在目前 v2.9.37 版本會將 playbook 內的 become: yes 跳過, 造成無法 sudo 的議題
* Workaround 的方式就是
- Key Store 建立一個只有密碼但無帳號的 login with password Exp. rkeuser-none 和有帳號密碼的 rkeuser 共同使用 \\ {{:tech:2024-01-02_104611.png?600|}}
- Inventory 中 User Credentials 選有帳號密碼的 Key, Sudo Credentials 選無帳號的 Key \\ {{:tech:2024-01-02_104933.png?600|}}
- 對於 task 無法 UI 找到刪除的問題
* 參考 - https://github.com/ansible-semaphore/semaphore/issues/1101
* 在目前 v2.9.37 版本, UI 還未提供這樣的功能, 所以必須透過 API 或改 DB 方式來解決
* API Swagger - https://www.semui.co/api-docs/
* [[tech/alpine_semaphore/api]]
* [[tech/alpine_semaphore/db]]
- 刪除或編輯 template 的 UI
* 之前沒看到, 突然 UI 出現可以刪除或編輯 template 功能 \\ {{:tech:2024-01-02_195145.png?600|}} \\ {{:tech:2024-01-02_195212.png?600|}}
- 執行時 log 內出現 failed_modules: ansible.legacy.setup: ansible_facts: discovered_interpreter_python: /usr/bin/python, failed: true
* 表示目標主機內可能未安裝 python, 需要先手動進行安裝 Exp. Alpine 目標主機apk add python3
===== 參考網址 =====
* https://www.youtube.com/watch?v=kP8Oda17k7Q
* https://docs.semui.co/administration-guide/installation#docker
* https://github.com/semaphoreui/semaphore
{{tag>ansible Semaphore alpine docker}}