Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of the latest compatible working version of Ansible with Ansible-Mitogen #2256

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions deployment/docker/runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,25 @@
WORKDIR /home/semaphore

# renovate: datasource=pypi depName=ansible
ENV ANSIBLE_VERSION 11.1.0
ARG ANSIBLE_VENV_PATH=/opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv

RUN apk add --no-cache -U python3-dev build-base openssl-dev libffi-dev cargo && \
mkdir -p ${ANSIBLE_VENV_PATH} && \
python3 -m venv ${ANSIBLE_VENV_PATH} --system-site-packages && \
source ${ANSIBLE_VENV_PATH}/bin/activate && \
pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests pywinrm && \
apk del python3-dev build-base openssl-dev libffi-dev cargo && \
rm -rf /var/cache/apk/* && \
find ${ANSIBLE_VENV_PATH} -iname __pycache__ | xargs rm -rf && \
chown -R semaphore:0 /opt/semaphore

USER 1001
RUN export MITOGEN_VERSION=$(curl -s https://api.github.com/repos/mitogen-hq/mitogen/releases/latest | grep '"tag_name":' | sed -E 's/.*"tag_name": "v([0-9.]+)".*/\1/') && \

Check warning on line 81 in deployment/docker/runner/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

deployment/docker/runner/Dockerfile#L81

Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`
export ANSIBLE_MAJOR_COMPAT_VERSION=$(curl -s https://raw.githubusercontent.com/mitogen-hq/mitogen/master/tox.ini | grep " ansible" | cut -d " " -f6 | grep ansible | tail -n1 | cut -d "=" -f2 | cut -d "." -f1) && \
export ANSIBLE_VERSION=$(pip index versions ansible | tr ',' '\n'| tr -d '()' | grep " ${ANSIBLE_MAJOR_COMPAT_VERSION}." | head -n1 | cut -d ' ' -f2) && \
export VIRTUAL_ENV=/opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv && \
echo "VIRTUAL_ENV=${VIRTUAL_ENV}" | tee -a /opt/semaphore/.env && \
apk add --no-cache -U python3-dev build-base openssl-dev libffi-dev cargo && \
mkdir -p ${VIRTUAL_ENV} && \
python3 -m venv ${VIRTUAL_ENV} --system-site-packages && \
source ${VIRTUAL_ENV}/bin/activate && \
pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} mitogen==${MITOGEN_VERSION} boto3 botocore requests pywinrm && \
echo -e "\nstrategy = mitogen_linear" >>/etc/ansible/ansible.cfg && \
echo "strategy_plugins = /opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv/lib/python3.11/site-packages/ansible_mitogen/plugins/strategy" >>/etc/ansible/ansible.cfg && \
apk del python3-dev build-base openssl-dev libffi-dev cargo && \
rm -rf /var/cache/apk/* && \
find ${VIRTUAL_ENV} -iname __pycache__ | xargs rm -rf && \
chown -R semaphore:0 /opt/semaphore

ENV VIRTUAL_ENV="$ANSIBLE_VENV_PATH"
ENV PATH="$ANSIBLE_VENV_PATH/bin:$PATH"
USER 1001

# Preventing ansible zombie processes. Tini kills zombies.
ENTRYPOINT ["/sbin/tini", "--"]
Expand Down
3 changes: 3 additions & 0 deletions deployment/docker/runner/runner-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ if test "$#" -ne 1; then
else
exec "$@"
fi

source /opt/semaphore/.env && export $(cut -d= -f1 < /opt/semaphore/.env)
export PATH="$VIRTUAL_ENV/bin:$PATH"
31 changes: 16 additions & 15 deletions deployment/docker/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@

ARG TARGETARCH="amd64"
# renovate: datasource=pypi depName=ansible
ARG ANSIBLE_VERSION=11.1.0
ENV ANSIBLE_VERSION=${ANSIBLE_VERSION}
ARG ANSIBLE_VENV_PATH=/opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv

RUN apk add --no-cache -U \
bash curl git gnupg mysql-client openssh-client-default python3 py3-pip rsync sshpass tar tini tzdata unzip wget zip jq && \
Expand Down Expand Up @@ -80,21 +77,25 @@

WORKDIR /home/semaphore

RUN apk add --no-cache -U python3-dev build-base openssl-dev libffi-dev cargo && \
mkdir -p ${ANSIBLE_VENV_PATH} && \
python3 -m venv ${ANSIBLE_VENV_PATH} --system-site-packages && \
source ${ANSIBLE_VENV_PATH}/bin/activate && \
pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests pywinrm && \
apk del python3-dev build-base openssl-dev libffi-dev cargo && \
rm -rf /var/cache/apk/* && \
find ${ANSIBLE_VENV_PATH} -iname __pycache__ | xargs rm -rf && \
chown -R semaphore:0 /opt/semaphore
RUN export MITOGEN_VERSION=$(curl -s https://api.github.com/repos/mitogen-hq/mitogen/releases/latest | grep '"tag_name":' | sed -E 's/.*"tag_name": "v([0-9.]+)".*/\1/') && \

Check warning on line 80 in deployment/docker/server/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

deployment/docker/server/Dockerfile#L80

Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`
export ANSIBLE_MAJOR_COMPAT_VERSION=$(curl -s https://raw.githubusercontent.com/mitogen-hq/mitogen/master/tox.ini | grep " ansible" | cut -d " " -f6 | grep ansible | tail -n1 | cut -d "=" -f2 | cut -d "." -f1) && \
export ANSIBLE_VERSION=$(pip index versions ansible | tr ',' '\n'| tr -d '()' | grep " ${ANSIBLE_MAJOR_COMPAT_VERSION}." | head -n1 | cut -d ' ' -f2) && \
export VIRTUAL_ENV=/opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv && \
echo "VIRTUAL_ENV=${VIRTUAL_ENV}" | tee -a /opt/semaphore/.env && \
apk add --no-cache -U python3-dev build-base openssl-dev libffi-dev cargo && \
mkdir -p ${VIRTUAL_ENV} && \
python3 -m venv ${VIRTUAL_ENV} --system-site-packages && \
source ${VIRTUAL_ENV}/bin/activate && \
pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} mitogen==${MITOGEN_VERSION} boto3 botocore requests pywinrm && \
echo -e "\nstrategy = mitogen_linear" >>/etc/ansible/ansible.cfg && \
echo "strategy_plugins = /opt/semaphore/apps/ansible/${ANSIBLE_VERSION}/venv/lib/python3.11/site-packages/ansible_mitogen/plugins/strategy" >>/etc/ansible/ansible.cfg && \
apk del python3-dev build-base openssl-dev libffi-dev cargo && \
rm -rf /var/cache/apk/* && \
find ${VIRTUAL_ENV} -iname __pycache__ | xargs rm -rf && \
chown -R semaphore:0 /opt/semaphore

USER 1001

ENV VIRTUAL_ENV="$ANSIBLE_VENV_PATH"
ENV PATH="$ANSIBLE_VENV_PATH/bin:$PATH"

# Preventing ansible zombie processes. Tini kills zombies.
ENTRYPOINT ["/sbin/tini", "--"]
CMD [ "/usr/local/bin/server-wrapper"]
3 changes: 3 additions & 0 deletions deployment/docker/server/server-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ file_env() {
unset "${1}_FILE"
}

source /opt/semaphore/.env && export $(cut -d= -f1 < /opt/semaphore/.env)
export PATH="$VIRTUAL_ENV/bin:$PATH"

export SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
export SEMAPHORE_DB_PATH="${SEMAPHORE_DB_PATH:-/var/lib/semaphore}"
export SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-}"
Expand Down
Loading