diff --git a/.drone.jsonnet b/.drone.jsonnet
index 78b1cfd..41e90b4 100644
--- a/.drone.jsonnet
+++ b/.drone.jsonnet
@@ -1,43 +1,39 @@
-local PipelineBuild(os='linux', arch='amd64', version='gce') = {
- local tag = os + '-' + arch,
- local version_tag = version + '-' + os + '-' + arch,
- local file_suffix = std.strReplace(version_tag, '-', '.'),
+local PipelineBuild(arch="amd64") = {
kind: "pipeline",
- name: version_tag,
+ name: "build-" + arch,
platform: {
- os: os,
+ os: "linux",
arch: arch,
},
steps: [
{
- name: 'dryrun',
- image: 'plugins/docker:' + tag,
- pull: 'always',
+ name: "dryrun",
+ image: "plugins/docker:18-linux-" + arch,
+ pull: "always",
settings: {
dry_run: true,
- tags: version_tag,
- dockerfile: 'docker/Dockerfile.' + file_suffix,
- repo: ' xoxys/molecule',
+ dockerfile: "Dockerfile",
+ repo: "xoxys/molecule",
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
},
},
{
- name: 'publish',
- image: 'plugins/docker:' + tag,
- pull: 'always',
+ name: "publish",
+ image: "plugins/docker:18-linux-" + arch,
+ pull: "always",
settings: {
auto_tag: true,
- auto_tag_suffix: version_tag,
- dockerfile: 'docker/Dockerfile.' + file_suffix,
- repo: ' xoxys/molecule',
+ auto_tag_suffix: arch,
+ dockerfile: "Dockerfile",
+ repo: "xoxys/molecule",
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
},
when: {
ref: [
- 'refs/heads/master',
- 'refs/tags/**',
+ "refs/heads/master",
+ "refs/tags/**",
],
},
},
@@ -64,8 +60,8 @@ local PipelineNotifications(depends_on=[]) = {
},
when: {
ref: [
- 'refs/heads/master',
- 'refs/tags/**',
+ "refs/heads/master",
+ "refs/tags/**",
],
},
},
@@ -83,8 +79,8 @@ local PipelineNotifications(depends_on=[]) = {
},
when: {
ref: [
- 'refs/heads/master',
- 'refs/tags/**',
+ "refs/heads/master",
+ "refs/tags/**",
],
},
},
@@ -97,27 +93,27 @@ local PipelineNotifications(depends_on=[]) = {
},
when: {
ref: [
- 'refs/heads/master',
- 'refs/tags/**',
+ "refs/heads/master",
+ "refs/tags/**",
],
},
},
{
name: "matrix",
image: "plugins/matrix",
- pull: 'always',
+ pull: "always",
settings: {
- homeserver: "https://matrix.rknet.org",
- roomid: "MtidqQXWWAtQcByBhH:rknet.org",
template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}",
+ roomid: { "from_secret": "matrix_roomid" },
+ homeserver: { "from_secret": "matrix_homeserver" },
username: { from_secret: "matrix_username" },
password: { from_secret: "matrix_password" },
},
when: {
status: [ "success", "failure" ],
ref: [
- 'refs/heads/master',
- 'refs/tags/**',
+ "refs/heads/master",
+ "refs/tags/**",
],
},
},
@@ -126,14 +122,8 @@ local PipelineNotifications(depends_on=[]) = {
};
[
- PipelineBuild(os='linux', arch='amd64', version='gce'),
- PipelineBuild(os='linux', arch='amd64', version='ec2'),
- PipelineBuild(os='linux', arch='amd64', version='do'),
- PipelineBuild(os='linux', arch='amd64', version='hcloud'),
+ PipelineBuild(arch="amd64"),
PipelineNotifications(depends_on=[
- "gce-linux-amd64",
- "ec2-linux-amd64",
- "do-linux-amd64",
- "hcloud-linux-amd64"
+ "build-amd64",
])
]
diff --git a/.drone.yml b/.drone.yml
index c6b974b..77fa5d9 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -1,6 +1,6 @@
---
kind: pipeline
-name: gce-linux-amd64
+name: build-amd64
platform:
os: linux
@@ -9,150 +9,32 @@ platform:
steps:
- name: dryrun
pull: always
- image: plugins/docker:linux-amd64
+ image: plugins/docker:18-linux-amd64
settings:
- dockerfile: docker/Dockerfile.gce.linux.amd64
+ dockerfile: Dockerfile
dry_run: true
password:
from_secret: docker_password
- repo: xoxys/molecule
- tags: gce-linux-amd64
+ repo: xoxys/molecule
username:
from_secret: docker_username
- name: publish
pull: always
- image: plugins/docker:linux-amd64
+ image: plugins/docker:18-linux-amd64
settings:
auto_tag: true
- auto_tag_suffix: gce-linux-amd64
- dockerfile: docker/Dockerfile.gce.linux.amd64
+ auto_tag_suffix: amd64
+ dockerfile: Dockerfile
password:
from_secret: docker_password
- repo: xoxys/molecule
+ repo: xoxys/molecule
username:
from_secret: docker_username
when:
ref:
- refs/heads/master
- - "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/**"
+ - refs/tags/**
---
kind: pipeline
@@ -176,7 +58,7 @@ steps:
when:
ref:
- refs/heads/master
- - "refs/tags/**"
+ - refs/tags/**
- name: readme
pull: always
@@ -193,7 +75,7 @@ steps:
when:
ref:
- refs/heads/master
- - "refs/tags/**"
+ - refs/tags/**
- name: microbadger
pull: always
@@ -204,35 +86,34 @@ steps:
when:
ref:
- refs/heads/master
- - "refs/tags/**"
+ - refs/tags/**
- name: matrix
pull: always
image: plugins/matrix
settings:
- homeserver: https://matrix.rknet.org
+ homeserver:
+ from_secret: matrix_homeserver
password:
from_secret: matrix_password
- roomid: MtidqQXWWAtQcByBhH:rknet.org
+ roomid:
+ from_secret: matrix_roomid
template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}"
username:
from_secret: matrix_username
when:
ref:
- refs/heads/master
- - "refs/tags/**"
+ - refs/tags/**
status:
- success
- failure
depends_on:
-- gce-linux-amd64
-- ec2-linux-amd64
-- do-linux-amd64
-- hcloud-linux-amd64
+- build-amd64
---
kind: signature
-hmac: d342ba3ba37c50e399140c367ac98635b4c0bd1b27f8ce453e09dceefd2e6e27
+hmac: b7673d73b46aee7bc3b1e56348114c6a6e1c03d3a43458f2302c87ea0c842eb8
...
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..dbf7a8b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,27 @@
+FROM python:3.7-alpine
+
+LABEL maintainer="Robert Kaussow " \
+ 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"]
diff --git a/README.md b/README.md
index a1ff029..7ec55cb 100644
--- a/README.md
+++ b/README.md
@@ -3,18 +3,12 @@
[![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")
-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
-`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`
-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.
diff --git a/do-entrypoint.sh b/do-entrypoint.sh
deleted file mode 100755
index f908a2c..0000000
--- a/do-entrypoint.sh
+++ /dev/null
@@ -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
diff --git a/docker/Dockerfile.do.linux.amd64 b/docker/Dockerfile.do.linux.amd64
deleted file mode 100644
index 26e5051..0000000
--- a/docker/Dockerfile.do.linux.amd64
+++ /dev/null
@@ -1,39 +0,0 @@
-FROM python:3.7-alpine
-
-LABEL maintainer="Robert Kaussow " \
- 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"]
diff --git a/docker/Dockerfile.ec2.linux.amd64 b/docker/Dockerfile.ec2.linux.amd64
deleted file mode 100644
index d065862..0000000
--- a/docker/Dockerfile.ec2.linux.amd64
+++ /dev/null
@@ -1,40 +0,0 @@
-FROM python:3.7-alpine
-
-LABEL maintainer="Robert Kaussow " \
- 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"]
diff --git a/docker/Dockerfile.gce.linux.amd64 b/docker/Dockerfile.gce.linux.amd64
deleted file mode 100644
index b27d96c..0000000
--- a/docker/Dockerfile.gce.linux.amd64
+++ /dev/null
@@ -1,42 +0,0 @@
-FROM python:3.7-alpine
-
-LABEL maintainer="Robert Kaussow " \
- 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"]
diff --git a/docker/Dockerfile.hcloud.linux.amd64 b/docker/Dockerfile.hcloud.linux.amd64
deleted file mode 100644
index 4dcd4ef..0000000
--- a/docker/Dockerfile.hcloud.linux.amd64
+++ /dev/null
@@ -1,39 +0,0 @@
-FROM python:3.7-alpine
-
-LABEL maintainer="Robert Kaussow " \
- 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"]
diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl
deleted file mode 100644
index 96f2633..0000000
--- a/docker/manifest.tmpl
+++ /dev/null
@@ -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
diff --git a/ec2-entrypoint.sh b/ec2-entrypoint.sh
deleted file mode 100755
index f908a2c..0000000
--- a/ec2-entrypoint.sh
+++ /dev/null
@@ -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
diff --git a/gce-entrypoint.sh b/gce-entrypoint.sh
deleted file mode 100755
index 70279a1..0000000
--- a/gce-entrypoint.sh
+++ /dev/null
@@ -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
diff --git a/hcloud-entrypoint.sh b/hcloud-entrypoint.sh
deleted file mode 100755
index f908a2c..0000000
--- a/hcloud-entrypoint.sh
+++ /dev/null
@@ -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
diff --git a/manifest.tmpl b/manifest.tmpl
new file mode 100644
index 0000000..1cdd812
--- /dev/null
+++ b/manifest.tmpl
@@ -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
diff --git a/overlay/bin/molecule b/overlay/bin/molecule
new file mode 100755
index 0000000..316b406
--- /dev/null
+++ b/overlay/bin/molecule
@@ -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 "$@"