How to get started running Ansible Semaphore in a podman pod
In the search of a more user friendly way to run playbooks for people unfamiliar with Ansible i stumbled across Semaphore and thought i'd give it a try. It promises a friendly UI , access control and logs with notifications for playbook runs. At first glance it looks like it may cut down on some of the complexity of AWX the upstream project for Ansible tower. Ansible-Semaphore main site
And they have an 'official' container build. Semaphore on Dockerhub
All sounds great.
While the handy availability of a docker build that probably did all i needed sounded great. Finding documentation from people who had run it was less prevalent.
The installation instructions for Semaphore are here https://github.com/ansible-semaphore/semaphore/wiki/Installation However they refer to an install on a base os only. I couldn't find anyone who ran this tool in podman either which is what my host is running.
They refer to running a mysql docker container to make a simple database and then running a script to install semaphore on the host.
After looking around a bit i found a snippet in a bug that talked about a docker-compose setup that could work.
https://github.com/ansible-semaphore/semaphore/issues/148
the key part was this docker compose file.
services:
mysql:
image: mariadb:10
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_DATABASE: semaphore
MYSQL_USER: semaphore
MYSQL_PASSWORD: semaphore
semaphore:
image: ansiblesemaphore/semaphore
environment:
SEMAPHORE_DB_USER: semaphore
SEMAPHORE_DB_PASS: semaphore
SEMAPHORE_DB_HOST: mysql
SEMAPHORE_DB_PORT: 3306
SEMAPHORE_DB: semaphore
SEMAPHORE_PLAYBOOK_PATH: /etc/semaphore
SEMAPHORE_ADMIN_PASSWORD: password
SEMAPHORE_ADMIN_NAME: "Developer"
SEMAPHORE_ADMIN_EMAIL: admin@localhost
SEMAPHORE_ADMIN: admin
SEMAPHORE_WEB_ROOT: http://192.168.185.10:3000
ports:
- "3000:3000"
depends_on:
- mysql
This gave me all of the key things i needed to include on the podman runs. This creates a podman pod which includes a pod , a
#!/bin/bash
podman pod create --name ansible -p 3306:3306 -p 3000:3000
podman run -d --name=mariadb --pod ansible -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=semaphore -e MYSQL_USER=semaphore -e MYSQL_PASSWORD=semaphore -v /opt/data/mysql/:/var/lib/mysql mariadb:10
podman run -d --name=semaphore --pod ansible -e SEMAPHORE_DB_USER=semaphore -e SEMAPHORE_DB_PASS=semaphore -e SEMAPHORE_DB_HOST=127.0.0.1 -e SEMAPHORE_DB_PORT=3306 -e SEMAPHORE_DB=semaphore -e SEMAPHORE_PLAYBOOK_PATH=/etc/semaphore -e SEMAPHORE_ADMIN_PASSWORD=password -e SEMAPHORE_ADMIN_NAME="Developer" -e SEMAPHORE_ADMIN_EMAIL=admin@localhost -e SEMAPHORE_ADMIN=admin -e SEMAPHORE_WEB_ROOT=http://172.30.10.120:3000 -v /opt/data/semaphore/:/opt/data/semaphore ansiblesemaphore/semaphore
Once this is in place a pod can be created
[root@awxncentos7 ansible-semaphore]# ./ansible-pod.sh
6228b13cc516489f1fefc15ab7df2ae7525fe10e331a89d762a7e27fb17f5abf
2f6a335a451549fbeb3ec6859adb779f1eb3d7b40c662fc46b7b1200a06fc54e
1eb5c45688098dfcaf3539024dc566fb23ddfe3f5b27a9c8541c5dd19563b0b4
[root@awxncentos7 ansible-semaphore]#
see below the ansible pod
[root@awxncentos7 ansible-semaphore]# podman pod ls
POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID
6228b13cc516 ansible Running 59 seconds ago 3 291de768890d
b5cdb5ff2e13 zorc Running 7 days ago 6 69ae2e5c6ce9
[root@awxncentos7 ansible-semaphore]#
And here are the containers running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1eb5c4568809 docker.io/ansiblesemaphore/semaphore:latest /usr/local/bin/se... 3 minutes ago Up 3 minutes ago 0.0.0.0:3000->3000/tcp semaphore
2f6a335a4515 docker.io/library/mariadb:10 mysqld 3 minutes ago Up 3 minutes ago 0.0.0.0:3000->3000/tcp mariadb
fad84eae5061 docker.io/gogs/gogs:latest /bin/s6-svscan /a... 3 hours ago Up 3 hours ago 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->3000/tcp gogs
you can read the log for the semaphore container to get a summary of the running config.
[root@awxncentos7 ansible-semaphore]# podman logs --tail 5 semaphore
Server is running
Checking DB migrations
Tmp Path (projects home) /tmp/semaphore
MySQL semaphore@127.0.0.1:3306 semaphore
Port :3000
[root@awxncentos7 ansible-semaphore]#
Once this is up and running you can go ahead and try set up semaphore as normal.