~evilham/cdist-evilham

a4e2a1d07f0bf38238659077e5a55cab3c3e5884 — Evilham 7 months ago d85c357
__woodpecker*: reimplement extra-args to take env vars

This requires latest cdist-contrib, which adds support for environment
variables to systemd and runit services.
8 files changed, 48 insertions(+), 47 deletions(-)

M type/__evilham_woodpecker_ci_agent/man.rst
M type/__evilham_woodpecker_ci_agent/manifest
R type/__evilham_woodpecker_ci_agent/parameter/default/{extra-args => env}
M type/__evilham_woodpecker_ci_agent/parameter/optional
M type/__evilham_woodpecker_ci_server/man.rst
M type/__evilham_woodpecker_ci_server/manifest
R type/__evilham_woodpecker_ci_server/parameter/default/{extra-args => env}
M type/__evilham_woodpecker_ci_server/parameter/optional
M type/__evilham_woodpecker_ci_agent/man.rst => type/__evilham_woodpecker_ci_agent/man.rst +15 -12
@@ 12,6 12,7 @@ DESCRIPTION
Woodpecker is an open source CI engine that uses docker to run pipelines. It
offers flexibility and extensibility.


OPTIONAL PARAMETERS
-------------------
user


@@ 22,27 23,29 @@ work-dir
    Alternative path for the storage of Woodpecker.
    Defaults to `/var/lib/woodpecker-agent`.

extra-args
    Extra arguments for configurating enviroment variables in
    woodpecker-server. This is the main way of setting up woodpecker. If it's
env
    Enviroment variables that will be passed to the `woodpecker-agent` binary.
    This is the main way of setting up woodpecker. If it's
    unused, the service will assing the default values of configuration.
    We recommend reading the woodpecker-ci documentation before starting.


EXAMPLES
--------

.. code-block:: sh

        # Setup woodpecker-server service
        __evilham_woodpecker_ci_agent agent1\
        --extra-args  "$(cat << DONE
export WOODPECKER_SERVER=woodpecker-ci.example.org:9000
export WOODPECKER_AGENT_SECRET=${AGENT_SECRET}
export WOODPECKER_BACKEND=docker
export WOODPECKER_LOG_LEVEL=trace
    # Setup woodpecker-server service
    __evilham_woodpecker_ci_agent agent1 \
        --env "$(cat <<- DONE
    WOODPECKER_SERVER=woodpecker-ci.example.org:9000
    WOODPECKER_AGENT_SECRET=${AGENT_SECRET}
    WOODPECKER_BACKEND=docker
    WOODPECKER_LOG_LEVEL=trace

    DONE
    )"

DONE
)"
SEE ALSO
--------
- `__evilham_woodpecker_ci_server(7)`

M type/__evilham_woodpecker_ci_agent/manifest => type/__evilham_woodpecker_ci_agent/manifest +5 -7
@@ 16,13 16,14 @@ TYPE_VERSION="0.15.7"
DOWNLOAD_URL="https://github.com/woodpecker-ci/woodpecker/releases/download/v${TYPE_VERSION}/woodpecker-agent_linux_amd64.tar.gz"

USER="$(cat "${__object}/parameter/user")"
EXTRA_ARGS="$(cat "${__object}/parameter/extra-args")"
ENV_FILE="${__object}/parameter/env"
DATA_PATH="$(cat "${__object}/parameter/work-dir")"

WORK_DIR="$(echo "${DATA_PATH}/${__object_id}")"

# Install and enable the service
__evilham_single_binary_service "${__object_id}"\
service_id="woodpecker-agent_${__object_id}"
__single_binary_service "${service_id}"\
	--user "${USER}" \
	--version "${TYPE_VERSION}" \
	--checksum "${CHECKSUM}" \


@@ 33,12 34,9 @@ __evilham_single_binary_service "${__object_id}"\
	--unpack \
	--unpack-extension ".tar.gz" \
	--binary "woodpecker-agent"\
	--custom-code "$(cat <<DONE
${EXTRA_ARGS}
DONE
)"
	--env "$(cat "${ENV_FILE}")"

# Create this instance's data dir, with restrictive permissions
require="__evilham_single_binary_service/${__object_id}" __directory \
require="__single_binary_service/${service_id}" __directory \
	"${WORK_DIR}" --state present \
	--mode 0750 --owner "${USER}" --group "${USER}"

R type/__evilham_woodpecker_ci_agent/parameter/default/extra-args => type/__evilham_woodpecker_ci_agent/parameter/default/env +0 -0
M type/__evilham_woodpecker_ci_agent/parameter/optional => type/__evilham_woodpecker_ci_agent/parameter/optional +1 -1
@@ 1,4 1,4 @@
extra-args
env
host
server
user

M type/__evilham_woodpecker_ci_server/man.rst => type/__evilham_woodpecker_ci_server/man.rst +22 -19
@@ 12,6 12,7 @@ DESCRIPTION
Woodpecker is an open source CI engine that uses docker to run pipelines. It
offers flexibility and extensibility.


OPTIONAL PARAMETERS
-------------------
user


@@ 22,33 23,35 @@ work-dir
    Alternative path for the storage of Woodpecker.
    Defaults to `/var/lib/woodpecker-server`.

extra-args
    Extra arguments for configurating enviroment variables in
    woodpecker-server. This is the main way of setting up woodpecker. If it's
env
    Enviroment variables that will be passed to the `woodpecker-agent` binary.
    This is the main way of setting up woodpecker. If it's
    unused, the service will assing the default values of configuration.
    We recommend reading the woodpecker-ci documentation before starting.


EXAMPLES
--------

.. code-block:: sh

        # Setup woodpecker-server service
        __evilham_woodpecker_ci_server --extra-args  "$(cat << DONE
export WOODPECKER_HOST=https://woodpecker-ci.example.org
export WOODPECKER_OPEN=true
export WOODPECKER_AGENT_SECRET=61c11e52146af3cf36d767eabb01971fd051f4d0da2320
export WOODPECKER_LOG_LEVEL=trace

export WOODPECKER_GITEA=true
export WOODPECKER_GITEA_URL=https://forgejo.example.org
export WOODPECKER_GITEA_CLIENT=9317652ea492c5b278b4e9c91cfd37
export WOODPECKER_GITEA_SECRET=4460d95b8a4852cbdba5c5776a0e678147c67086441c1

export WOODPECKER_DATABASE_DRIVER=postgres
export WOODPECKER_DATABASE_DATASOURCE=postgresql://wp@postgresql.exa:5432/wpdb
DONE
)"
    # Setup woodpecker-server service
    __evilham_woodpecker_ci_server \
        --extra-args  "$(cat <<- DONE
    WOODPECKER_HOST=https://woodpecker-ci.example.org
    WOODPECKER_OPEN=true
    WOODPECKER_AGENT_SECRET=61c11e52146af3cf36d767eabb01971fd051f4d0da2320
    WOODPECKER_LOG_LEVEL=trace

    WOODPECKER_GITEA=true
    WOODPECKER_GITEA_URL=https://forgejo.example.org
    WOODPECKER_GITEA_CLIENT=9317652ea492c5b278b4e9c91cfd37
    WOODPECKER_GITEA_SECRET=4460d95b8a4852cbdba5c5776a0e678147c67086441c1

    WOODPECKER_DATABASE_DRIVER=postgres
    WOODPECKER_DATABASE_DATASOURCE=postgresql://wp@postgresql.exa:5432/wpdb
    DONE
    )"

SEE ALSO
--------

M type/__evilham_woodpecker_ci_server/manifest => type/__evilham_woodpecker_ci_server/manifest +4 -7
@@ 16,11 16,11 @@ TYPE_VERSION="0.15.7"
DOWNLOAD_URL="https://github.com/woodpecker-ci/woodpecker/releases/download/v${TYPE_VERSION}/woodpecker-server_linux_amd64.tar.gz"

USER="$(cat "${__object}/parameter/user")"
EXTRA_ARGS="$(cat "${__object}/parameter/extra-args")"
ENV_FILE="${__object}/parameter/env"
WORK_DIR="$(cat "${__object}/parameter/work-dir")"

# Install and enable the service
__evilham_single_binary_service woodpecker-server \
__single_binary_service woodpecker-server \
	--user "${USER}" \
	--version "${TYPE_VERSION}" \
	--checksum "${CHECKSUM}" \


@@ 31,13 31,10 @@ __evilham_single_binary_service woodpecker-server \
	--unpack \
	--unpack-extension ".tar.gz" \
	--binary "woodpecker-server"\
	--custom-code "$(cat << DONE
${EXTRA_ARGS}
DONE
)"
	--env "$(cat "${ENV_FILE}")"


# Create this instance's data dir, with restrictive permissions
require="__evilham_single_binary_service/woodpecker-server" __directory \
require="__single_binary_service/woodpecker-server" __directory \
	"${WORK_DIR}" --state present \
	--mode 0750 --owner "${USER}" --group "${USER}"

R type/__evilham_woodpecker_ci_server/parameter/default/extra-args => type/__evilham_woodpecker_ci_server/parameter/default/env +0 -0
M type/__evilham_woodpecker_ci_server/parameter/optional => type/__evilham_woodpecker_ci_server/parameter/optional +1 -1
@@ 1,3 1,3 @@
extra-args
env
user
work-dir