Hi. First I want to add a short description and several links about what is Ansible and what is Ansible-semaphore.
Ansible® is an open-source, command-line IT automation software application written in Python. It can configure systems, deploy software, and orchestrate advanced workflows to support application deployment, system updates, and more.
https://docs.ansible.com/ansible/latest/getting_started/index.html
Ansible Semaphore is beautiful web interface for running Ansible playbooks. https://www.ansible-semaphore.com/
Situation:
I have an old Synology NAS, actually, it is Xpenology on a small PC.
And I learning DevOps tools, like Ansible now, so I decided to use Ansible-Semaphore for the orchestration of my playbooks and inventory files.
Task:
At first sight, it is a simple task who works with Ansible and Docker before. We need to install Docker on Synology NAS and create Ansible-semaphore docker-compose file that we can find in the official documentation. But I had some problem and want to write about it.
Action:
So the steps to do are:
Install docker on Synology. This is a pretty simple step and there is a lot of documentation. So I skip it in this article. One thing that you need to know, is that with docker Synology's packet manager automatically installs and docker-compose, and this is pretty cool.
Login via ssh to our Synology NAS and create working folders for our project. (it is just an example, you can use your own hierarchy)
cd /volume1
mkdir docker docker/docker-compose/ docker/docker-compose/semaphore
mkdir docker/semaphore docker/semaphore/etc
mkdir docker/mysql docker/mysql/mysql1
cd docker/docker-compose/semaphore
touch docker-compose.yml
- Now we need to edit docker-compose.yml file for our containers. And for this, we will use the official Ansible-semaphore docker-compose file but with small changes.
Also for Database we will use Mysql.
Here is the final code (not ideal, but). Which will be explained below.
version: '3.8'
services:
database:
image: mysql:8
container_name: Mysql
restart: always
volumes:
- /volume1/docker/mysql/mysql1:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 123456 #CHANGEME
MYSQL_DATABASE: semaphore #CHANGEME
MYSQL_USER: semaphore #CHANGEME
MYSQL_PASSWORD: 123456 #CHANGEME
networks:
- web-network
semaphore:
ports:
- 3000:3000
image: semaphoreui/semaphore:latest
user: "0:0" #here is a trick
environment:
SEMAPHORE_DB_USER: semaphore #CHANGEME
SEMAPHORE_DB_PASS: 123456 #CHANGEME
SEMAPHORE_DB_HOST: Mysql
SEMAPHORE_DB_PORT: 3306
SEMAPHORE_DB: semaphore #CHANGEME
SEMAPHORE_DB_DIALECT: mysql
SEMAPHORE_ADMIN_PASSWORD: 123456 #CHANGEME
SEMAPHORE_ADMIN_NAME: admin #CHANGEME
SEMAPHORE_ADMIN_EMAIL: admin@localhost #CHANGEME
SEMAPHORE_ADMIN: admin #CHANGEME
SEMAPHORE_PLAYBOOK_PATH: /tmp/semaphore/
SEMAPHORE_ACCESS_KEY_ENCRYPTION: 2zEAp6EtCT2RynaZmiV3ZzMd3Rcp7oM0 #CHANGEME
volumes:
- /volume1/docker/semaphore/etc:/etc/semaphore
networks:
- web-network
networks:
web-network:
driver: bridge
As you can see it is pretty simple (Database container and Semaphore container in one network), but there is one section that not mention in official docs.
user: "0:0"
When I tried to do docker-compose up without it I got the error:
It looks like a problem with rights. The user in the Semaphore container has no permission to write on disk.
I tried to do the same not on Synology but on Ubuntu server with Docker and got the same error.
So after some research, I found the guy who has a video with a Semaphore tutorial and git repository. In the video, he did not mention my error but in his git repository I saw this line (that I added to my docker-compose to solve the problem) in the docker-compose file:
user: "${UID}:${GID}"
As I understand (I still learn docker), our containers will use our local user id and group that have the necessary rights. Push me if I misunderstand it in the comments
When I added it to my Semaphore docker-compose file on my Ubuntu server, everything started two works. But on Synology NAS this command ${UID} does not return the user id, so I changed it to the root user id. Maybe it is not good from a security perspective, but it is my HomeLab and just only for test.
- So after all, in a folder with docker-compose file we run the command
docker-compose up
And everything eventually started as expected.
Result:
As a result, we successfully deployed Ansible-semaphore in Docker container on Synology NAS. How to use it - it is another topic.
Thank you for reading.
Feel free to live comments with critics or not.
Top comments (0)