refactoring and drop driverbased molecule builds
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2019-11-22 21:52:56 +01:00
parent 38342a918f
commit d60bb68345
15 changed files with 115 additions and 427 deletions

View File

@ -1,43 +1,39 @@
local PipelineBuild(os='linux', arch='amd64', version='gce') = { local PipelineBuild(arch="amd64") = {
local tag = os + '-' + arch,
local version_tag = version + '-' + os + '-' + arch,
local file_suffix = std.strReplace(version_tag, '-', '.'),
kind: "pipeline", kind: "pipeline",
name: version_tag, name: "build-" + arch,
platform: { platform: {
os: os, os: "linux",
arch: arch, arch: arch,
}, },
steps: [ steps: [
{ {
name: 'dryrun', name: "dryrun",
image: 'plugins/docker:' + tag, image: "plugins/docker:18-linux-" + arch,
pull: 'always', pull: "always",
settings: { settings: {
dry_run: true, dry_run: true,
tags: version_tag, dockerfile: "Dockerfile",
dockerfile: 'docker/Dockerfile.' + file_suffix, repo: "xoxys/molecule",
repo: ' xoxys/molecule',
username: { from_secret: "docker_username" }, username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" }, password: { from_secret: "docker_password" },
}, },
}, },
{ {
name: 'publish', name: "publish",
image: 'plugins/docker:' + tag, image: "plugins/docker:18-linux-" + arch,
pull: 'always', pull: "always",
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: version_tag, auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + file_suffix, dockerfile: "Dockerfile",
repo: ' xoxys/molecule', repo: "xoxys/molecule",
username: { from_secret: "docker_username" }, username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" }, password: { from_secret: "docker_password" },
}, },
when: { when: {
ref: [ ref: [
'refs/heads/master', "refs/heads/master",
'refs/tags/**', "refs/tags/**",
], ],
}, },
}, },
@ -64,8 +60,8 @@ local PipelineNotifications(depends_on=[]) = {
}, },
when: { when: {
ref: [ ref: [
'refs/heads/master', "refs/heads/master",
'refs/tags/**', "refs/tags/**",
], ],
}, },
}, },
@ -83,8 +79,8 @@ local PipelineNotifications(depends_on=[]) = {
}, },
when: { when: {
ref: [ ref: [
'refs/heads/master', "refs/heads/master",
'refs/tags/**', "refs/tags/**",
], ],
}, },
}, },
@ -97,27 +93,27 @@ local PipelineNotifications(depends_on=[]) = {
}, },
when: { when: {
ref: [ ref: [
'refs/heads/master', "refs/heads/master",
'refs/tags/**', "refs/tags/**",
], ],
}, },
}, },
{ {
name: "matrix", name: "matrix",
image: "plugins/matrix", image: "plugins/matrix",
pull: 'always', pull: "always",
settings: { settings: {
homeserver: "https://matrix.rknet.org",
roomid: "MtidqQXWWAtQcByBhH:rknet.org",
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}", template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
roomid: { "from_secret": "matrix_roomid" },
homeserver: { "from_secret": "matrix_homeserver" },
username: { from_secret: "matrix_username" }, username: { from_secret: "matrix_username" },
password: { from_secret: "matrix_password" }, password: { from_secret: "matrix_password" },
}, },
when: { when: {
status: [ "success", "failure" ], status: [ "success", "failure" ],
ref: [ ref: [
'refs/heads/master', "refs/heads/master",
'refs/tags/**', "refs/tags/**",
], ],
}, },
}, },
@ -126,14 +122,8 @@ local PipelineNotifications(depends_on=[]) = {
}; };
[ [
PipelineBuild(os='linux', arch='amd64', version='gce'), PipelineBuild(arch="amd64"),
PipelineBuild(os='linux', arch='amd64', version='ec2'),
PipelineBuild(os='linux', arch='amd64', version='do'),
PipelineBuild(os='linux', arch='amd64', version='hcloud'),
PipelineNotifications(depends_on=[ PipelineNotifications(depends_on=[
"gce-linux-amd64", "build-amd64",
"ec2-linux-amd64",
"do-linux-amd64",
"hcloud-linux-amd64"
]) ])
] ]

View File

@ -1,6 +1,6 @@
--- ---
kind: pipeline kind: pipeline
name: gce-linux-amd64 name: build-amd64
platform: platform:
os: linux os: linux
@ -9,24 +9,23 @@ platform:
steps: steps:
- name: dryrun - name: dryrun
pull: always pull: always
image: plugins/docker:linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
dockerfile: docker/Dockerfile.gce.linux.amd64 dockerfile: Dockerfile
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/molecule repo: xoxys/molecule
tags: gce-linux-amd64
username: username:
from_secret: docker_username from_secret: docker_username
- name: publish - name: publish
pull: always pull: always
image: plugins/docker:linux-amd64 image: plugins/docker:18-linux-amd64
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: gce-linux-amd64 auto_tag_suffix: amd64
dockerfile: docker/Dockerfile.gce.linux.amd64 dockerfile: Dockerfile
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/molecule repo: xoxys/molecule
@ -35,124 +34,7 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
---
kind: pipeline
name: ec2-linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
settings:
dockerfile: docker/Dockerfile.ec2.linux.amd64
dry_run: true
password:
from_secret: docker_password
repo: xoxys/molecule
tags: ec2-linux-amd64
username:
from_secret: docker_username
- name: publish
pull: always
image: plugins/docker:linux-amd64
settings:
auto_tag: true
auto_tag_suffix: ec2-linux-amd64
dockerfile: docker/Dockerfile.ec2.linux.amd64
password:
from_secret: docker_password
repo: xoxys/molecule
username:
from_secret: docker_username
when:
ref:
- refs/heads/master
- "refs/tags/**"
---
kind: pipeline
name: do-linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
settings:
dockerfile: docker/Dockerfile.do.linux.amd64
dry_run: true
password:
from_secret: docker_password
repo: xoxys/molecule
tags: do-linux-amd64
username:
from_secret: docker_username
- name: publish
pull: always
image: plugins/docker:linux-amd64
settings:
auto_tag: true
auto_tag_suffix: do-linux-amd64
dockerfile: docker/Dockerfile.do.linux.amd64
password:
from_secret: docker_password
repo: xoxys/molecule
username:
from_secret: docker_username
when:
ref:
- refs/heads/master
- "refs/tags/**"
---
kind: pipeline
name: hcloud-linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
settings:
dockerfile: docker/Dockerfile.hcloud.linux.amd64
dry_run: true
password:
from_secret: docker_password
repo: xoxys/molecule
tags: hcloud-linux-amd64
username:
from_secret: docker_username
- name: publish
pull: always
image: plugins/docker:linux-amd64
settings:
auto_tag: true
auto_tag_suffix: hcloud-linux-amd64
dockerfile: docker/Dockerfile.hcloud.linux.amd64
password:
from_secret: docker_password
repo: xoxys/molecule
username:
from_secret: docker_username
when:
ref:
- refs/heads/master
- "refs/tags/**"
--- ---
kind: pipeline kind: pipeline
@ -176,7 +58,7 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- name: readme - name: readme
pull: always pull: always
@ -193,7 +75,7 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- name: microbadger - name: microbadger
pull: always pull: always
@ -204,35 +86,34 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
- name: matrix - name: matrix
pull: always pull: always
image: plugins/matrix image: plugins/matrix
settings: settings:
homeserver: https://matrix.rknet.org homeserver:
from_secret: matrix_homeserver
password: password:
from_secret: matrix_password from_secret: matrix_password
roomid: MtidqQXWWAtQcByBhH:rknet.org roomid:
from_secret: matrix_roomid
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}" template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
username: username:
from_secret: matrix_username from_secret: matrix_username
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
status: status:
- success - success
- failure - failure
depends_on: depends_on:
- gce-linux-amd64 - build-amd64
- ec2-linux-amd64
- do-linux-amd64
- hcloud-linux-amd64
--- ---
kind: signature kind: signature
hmac: d342ba3ba37c50e399140c367ac98635b4c0bd1b27f8ce453e09dceefd2e6e27 hmac: b7673d73b46aee7bc3b1e56348114c6a6e1c03d3a43458f2302c87ea0c842eb8
... ...

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM python:3.7-alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="molecule" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/molecule" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV PY_COLORS=1
COPY overlay/ /
RUN \
apk add --update --no-cache --virtual .build-deps gcc make libffi-dev musl-dev \
openssl-dev python-dev && \
apk add --update --no-cache git openssh-client && \
pip install --upgrade --no-cache-dir pip setuptools && \
pip install --no-cache-dir ansible~=2.9.0 pycrypto boto boto3 botocore hcloud \
apache-libcloud molecule && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
rm -rf /root/.cache/
USER root
CMD []
ENTRYPOINT ["/bin/molecule"]

View File

@ -3,18 +3,12 @@
[![Build Status](https://drone.rknet.org/api/badges/docker/molecule/status.svg)](https://drone.rknet.org/docker/molecule/) [![Build Status](https://drone.rknet.org/api/badges/docker/molecule/status.svg)](https://drone.rknet.org/docker/molecule/)
[![](https://images.microbadger.com/badges/image/xoxys/molecule.svg)](https://microbadger.com/images/xoxys/molecule "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/image/xoxys/molecule.svg)](https://microbadger.com/images/xoxys/molecule "Get your own image badge on microbadger.com")
Docker image to automate Ansible deployment tests with Molecule. The image was build to use with any docker based CI system. Currently the image is only available for the Google Compute Engine (GCE) backend of Molecule. Docker image to automate Ansible deployment tests with Molecule. The image was build to use with any docker based CI system.
## Environment variables ## Environment variables
`GCE_SSH_KEY`
ssh key to authenticate to your GCE project vms
`GCE_CREDENTIALS_JSON`
json file which holds your credentials to talk to the GCE api (must be generetade and exportet in GCE web console)
`GCE_CREDENTIALS_FILE`
path to the cretendtials file inside the container to write your $GCE_CREDENTIALS_JSON to
`MOLECULE_CUSTOM_MODULES_REPO` `MOLECULE_CUSTOM_MODULES_REPO`
if you use custom modules you can specify a git repo containing these files. The repo will be cloned so ansible can use it If you use custom modules you can specify a git repo containing these files. The repo will be cloned so ansible can use it.
`MOLECULE_CUSTOM_FILTERS_REPO`
If you have custom filters you can specify a git repo containing these files.

View File

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
set -o errtrace
set -o errexit
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
mkdir ./library/
git clone "$MOLECULE_CUSTOM_MODULES_REPO" ./library/
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
mkdir -p ./plugins/filters/
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" ./plugins/filters/
fi

View File

@ -1,39 +0,0 @@
FROM python:3.7-alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="molecule" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/molecule" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV PACKAGES="\
gcc \
make \
bash \
libffi-dev \
musl-dev \
openssl-dev \
python-dev \
git \
openssh-client \
"
ENV PIP_PACKAGES="\
ansible~=2.8.0 \
molecule[digitalocean] \
virtualenv \
pycrypto \
"
COPY ./do-entrypoint.sh /docker-entrypoint.sh
RUN \
apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& rm -rf /var/cache/apk/* \
&& pip install --upgrade --no-cache-dir pip \
&& pip install --no-cache-dir ${PIP_PACKAGES} \
&& rm -rf /root/.cache/
USER root
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,40 +0,0 @@
FROM python:3.7-alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="molecule" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/molecule" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV PACKAGES="\
gcc \
make \
bash \
libffi-dev \
musl-dev \
openssl-dev \
python-dev \
git \
openssh-client \
"
ENV PIP_PACKAGES="\
ansible~=2.8.0 \
molecule[ec2] \
virtualenv \
apache-libcloud \
pycrypto \
"
COPY ./ec2-entrypoint.sh /docker-entrypoint.sh
RUN \
apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& rm -rf /var/cache/apk/* \
&& pip install --upgrade --no-cache-dir pip \
&& pip install --no-cache-dir ${PIP_PACKAGES} \
&& rm -rf /root/.cache/
USER root
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,42 +0,0 @@
FROM python:3.7-alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="molecule" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/molecule" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV PACKAGES="\
gcc \
make \
bash \
libffi-dev \
musl-dev \
openssl-dev \
python-dev \
git \
openssh-client \
"
ENV PIP_PACKAGES="\
ansible~=2.8.0 \
molecule[gce] \
virtualenv \
apache-libcloud \
pycrypto \
"
COPY ./gce-entrypoint.sh /docker-entrypoint.sh
RUN \
apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& rm -rf /var/cache/apk/* \
&& pip install --upgrade --no-cache-dir pip \
&& pip install --no-cache-dir ${PIP_PACKAGES} \
&& rm -rf /root/.cache/ \
&& mkdir /root/.ssh \
&& chmod 700 /root/.ssh
USER root
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,39 +0,0 @@
FROM python:3.7-alpine
LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.name="molecule" \
org.label-schema.vcs-url="https://gitea.rknet.org/docker/molecule" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV PACKAGES="\
gcc \
make \
bash \
libffi-dev \
musl-dev \
openssl-dev \
python-dev \
git \
openssh-client \
"
ENV PIP_PACKAGES="\
ansible~=2.8.0 \
molecule[hetznercloud] \
pycrypto \
hcloud \
"
COPY ./hcloud-entrypoint.sh /docker-entrypoint.sh
RUN \
apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& rm -rf /var/cache/apk/* \
&& pip install --upgrade --no-cache-dir pip \
&& pip install --no-cache-dir ${PIP_PACKAGES} \
&& rm -rf /root/.cache/
USER root
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -1,12 +0,0 @@
image: xoxys/molecule:latest
manifests:
-
image: xoxys/molecule:gce-linux-amd64
platform:
architecture: amd64
os: linux
-
image: xoxys/molecule:ec2-linux-amd64
platform:
architecture: amd64
os: linux

View File

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
set -o errtrace
set -o errexit
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
mkdir ./library/
git clone "$MOLECULE_CUSTOM_MODULES_REPO" ./library/
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
mkdir -p ./plugins/filters/
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" ./plugins/filters/
fi

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
set -o errtrace
set -o errexit
if [ "$GCE_SSH_KEY" ]; then
echo "$GCE_SSH_KEY" > $HOME/.ssh/google_compute_engine
chmod 600 $HOME/.ssh/google_compute_engine
fi
if [ "$GCE_CREDENTIALS_JSON" ] && [ "$GCE_CREDENTIALS_FILE" ]; then
DIR=$(dirname "$GCE_CREDENTIALS_FILE")
mkdir -p "${DIR}"
echo "$GCE_CREDENTIALS_JSON" > "$GCE_CREDENTIALS_FILE"
fi
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
mkdir ./library/
git clone "$MOLECULE_CUSTOM_MODULES_REPO" ./library/
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
mkdir -p ./plugins/filters/
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" ./plugins/filters/
fi

View File

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
set -o errtrace
set -o errexit
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
mkdir ./library/
git clone "$MOLECULE_CUSTOM_MODULES_REPO" ./library/
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
mkdir -p ./plugins/filters/
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" ./plugins/filters/
fi

12
manifest.tmpl Normal file
View File

@ -0,0 +1,12 @@
image: xoxys/molecule:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: xoxys/molecule:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
platform:
architecture: amd64
os: linux

23
overlay/bin/molecule Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -eo pipefail
LIBRARY_DIR=$(pwd)library/
FILTERS_DIR=$(pwd)plugins/filters/
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
echo "Cloning custom modules..."
[ -d "${iLIBRARY_DIR}" ] && rm -rf "${LIBRARY_DIR}"
mkdir -p "${LIBRARY_DIR}"
git clone "${MOLECULE_CUSTOM_MODULES_REPO}" "{LIBRARY_DIR}" 2> /dev/null
echo
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
echo "Cloning custom filters..."
[ -d "${FILTERS_DIR}" ] && rm -rf "${FILTERS_DIR}"
mkdir -p "${FILTERS_DIR}"
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "${FILTERS_DIR}" 2> /dev/null
echo
fi
exec /usr/local/bin/molecule "$@"