semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

docker: install ansible-galaxy contents if desired

Open commx opened this issue 1 year ago • 3 comments

This PR adds the ability to install ansible-galaxy collections and roles on Semaphore startup when using the Docker image, so collections and/or roles don't need to be installed every time a task is launched.

The approach is very similar to what can be accomplished with the "pre-commands" in the systemd service as described in the manual installation section of the administration guide.

Assuming you have the following requirements.yml:

---
collections:
  - name: ansible.posix
    version: "1.5.4"

roles:
  - name: geeringguy.node_exporter
    version: "2.1.0"

Mount it to the Semaphore container with the docker compose service entry:

---
services:
  semaphore:
    image: semaphoreui/semaphore:latest
    environment: {}
    volumes:
      - path/to/requirements.yml:/etc/semaphore/requirements.yml:ro

commx avatar Apr 24 '24 18:04 commx

Really unsure about this feature. Installing python dependencies totally makes sense because they are required by collections, but collections itself could also be easily installed as part of the jobs within semaphore.

tboerger avatar Apr 28 '24 19:04 tboerger

Really unsure about this feature. Installing python dependencies totally makes sense because they are required by collections, but collections itself could also be easily installed as part of the jobs within semaphore.

Yes indeed and that's what we currently do. This feature is basically based on a customer scenario where a lot of collections/roles have to be installed for each task invocation. This takes a few minutes before the actual playbook runs, because their internet bandwidth capacity is quite limited. Installing those during semaphore startup can save quite some time and bandwith, especially in situations where galaxy contents are reused often so they don't need to get installed over and over again.

commx avatar Apr 28 '24 19:04 commx

@commx I use semaphore in a similar scenario. We've simply revised the container as a whole, depend on the original and build our dependencies into the container we build:

FROM semaphoreui/semaphore:latest

USER root

RUN apk update && apk add py3-pip py3-setuptools alpine-sdk make gcc \
         wget python3-dev jq postgresql-libs postgresql-client

RUN apk add --virtual .build-deps gcc musl-dev postgresql-dev

COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt

# More to do requirements from galaxy etc. etc. etc.

WORKDIR /home/semaphore
USER semaphore

andreas-marschke avatar May 03 '24 10:05 andreas-marschke