Merge pull request #811 from jdhayes/develop

Added ansible limit to API
This commit is contained in:
Denis Gukov 2022-06-23 17:02:21 +05:00 committed by GitHub
commit 261719137a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 0 deletions

View File

@ -1441,6 +1441,8 @@ paths:
type: string
environment:
type: string
limit:
type: string
responses:
201:
description: Task queued

View File

@ -29,6 +29,7 @@ type Task struct {
// override variables
Playbook string `db:"playbook" json:"playbook"`
Environment string `db:"environment" json:"environment"`
Limit string `db:"limit" json:"limit"`
UserID *int `db:"user_id" json:"user_id"`

View File

@ -0,0 +1,54 @@
Bootstrap: docker
From: golang:1.16.3-alpine3.13
Stage: spython-base
%setup
mkdir $SINGULARITY_ROOTFS/bigdata
%post
SEMAPHORE_VERSION="development"
SEMAPHORE_ARCH="linux_amd64"
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
APP_ROOT="/mnt/"
# hadolint ignore=DL3013
apk add --no-cache sshpass git mysql-client python3 py3-pip py-openssl openssl ca-certificates curl curl-dev openssh-client tini nodejs nodejs-npm bash rsync && \
apk --update add --virtual build-dependencies python3-dev libffi-dev openssl-dev build-base &&\
rm -rf /var/cache/apk/*
pip3 install --upgrade pip cffi && \
pip3 install ansible &&\
apk del build-dependencies
adduser -D -u 1002 -g 0 semaphore && \
mkdir -p $APP_ROOT && \
mkdir -p /tmp/semaphore && \
mkdir -p /etc/semaphore && \
chown -R semaphore:0 /go && \
chown -R semaphore:0 /tmp/semaphore && \
chown -R semaphore:0 /etc/semaphore && \
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
ssh-keyscan -H github.com > /root/.ssh/known_hosts
cd $(go env GOPATH) && curl -sL https://taskfile.dev/install.sh | sh
# Copy in app source
cd ${APP_ROOT}
./deployment/docker/ci/bin/install
su - semaphore # USER semaphore
# EXPOSE 3000
%environment
export SEMAPHORE_VERSION="development"
export SEMAPHORE_ARCH="linux_amd64"
export SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
export APP_ROOT="/mnt/"
%runscript
cd ${APP_ROOT}
exec /usr/local/bin/semaphore-wrapper ./bin/semaphore server --config /etc/semaphore/config.json "$@"
%startscript
cd ${APP_ROOT}
exec /usr/local/bin/semaphore-wrapper ./bin/semaphore server --config /etc/semaphore/config.json "$@"

View File

@ -0,0 +1,29 @@
#!/bin/bash -l
# Set env
SUSER=$USER
SCRIPT_HOME=$(realpath $(dirname $0))
SEMAPHORE_HOME=$(realpath $SCRIPT_HOME/../../../../)
echo "Building in $SEMAPHORE_HOME"
if [[ ! -f $SCRIPT_HOME/../semaphore.simg ]]; then
# Build Image
sudo bash -lc "
# Set env
module purge
module load singularity || echo 'Not using modules'
export SINGULARITY_BIND=${SEMAPHORE_HOME}:/mnt
# Build image
cd $SCRIPT_HOME/../ && singularity build semaphore.simg Singularity
# Update perms
chmod -R ${SUSER}: $SEMAPHORE_HOME"
else
# Build RPM
module load singularity || echo 'Not using modules'
cd ${SEMAPHORE_HOME} && singularity exec $SCRIPT_HOME/../semaphore.simg task release
chmod a+rx ${SEMAPHORE_HOME}/bin
chmod a+r ${SEMAPHORE_HOME}/bin/*
fi

View File

@ -696,6 +696,7 @@ func (t *TaskRunner) getPlaybookArgs() (args []string, err error) {
return
}
}
var taskExtraArgs []string
if t.template.AllowOverrideArgsInTask && t.task.Arguments != nil {
@ -705,6 +706,11 @@ func (t *TaskRunner) getPlaybookArgs() (args []string, err error) {
return
}
}
if t.task.Limit != "" {
t.Log("--limit="+t.task.Limit)
taskExtraArgs = append(taskExtraArgs, "--limit="+t.task.Limit)
}
args = append(args, templateExtraArgs...)
args = append(args, taskExtraArgs...)