Compare commits

..

No commits in common. "main" and "v3.0.2-1" have entirely different histories.

22 changed files with 371 additions and 326 deletions

View File

@ -1 +0,0 @@
Ansible

148
.drone.jsonnet Normal file
View File

@ -0,0 +1,148 @@
local PipelineBuild(arch='amd64') = {
kind: 'pipeline',
name: 'build-' + arch,
platform: {
os: 'linux',
arch: arch,
},
steps: [
{
name: 'dryrun',
image: 'plugins/docker',
settings: {
dry_run: true,
dockerfile: 'Dockerfile',
repo: 'xoxys/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
build_args: [
'BUILD_VERSION=${DRONE_TAG%-*}',
],
},
when: {
ref: [
'refs/pull/**',
],
},
},
{
name: 'publish',
image: 'plugins/docker',
settings: {
auto_tag: true,
auto_tag_suffix: arch,
dockerfile: 'Dockerfile',
repo: 'xoxys/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
build_args: [
'BUILD_VERSION=${DRONE_TAG%-*}',
],
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
},
},
{
name: 'publish-gitea',
image: 'plugins/gitea-release',
settings: {
api_key: { from_secret: 'gitea_token' },
base_url: 'https://gitea.rknet.org',
overwrite: true,
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
when: {
ref: ['refs/tags/**'],
},
},
],
};
local PipelineNotifications(depends_on=[]) = {
kind: 'pipeline',
name: 'notifications',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
image: 'plugins/manifest',
name: 'manifest',
settings: {
ignore_missing: true,
tags: [
'${DRONE_TAG}',
'${DRONE_TAG%-*}',
'${DRONE_TAG%.*}',
'${DRONE_TAG%%.*}',
],
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
spec: 'manifest.tmpl',
},
when: {
status: [
'success',
],
},
},
{
name: 'readme',
image: 'sheogorath/readme-to-dockerhub',
environment: {
DOCKERHUB_USERNAME: { from_secret: 'docker_username' },
DOCKERHUB_PASSWORD: { from_secret: 'docker_password' },
DOCKERHUB_REPO_PREFIX: 'xoxys',
DOCKERHUB_REPO_NAME: '${DRONE_REPO_NAME}',
README_PATH: 'README.md',
SHORT_DESCRIPTION: 'Molecule - Automated Ansible roles testing',
},
when: {
status: [
'success',
],
},
},
{
name: 'matrix',
image: 'plugins/matrix',
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
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 }}',
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
when: {
status: [
'success',
'failure',
],
},
},
],
trigger: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
status: [
'success',
'failure',
],
},
depends_on: depends_on,
};
[
PipelineBuild(arch='amd64'),
PipelineNotifications(depends_on=[
'build-amd64',
]),
]

131
.drone.yml Normal file
View File

@ -0,0 +1,131 @@
---
kind: pipeline
name: build-amd64
platform:
os: linux
arch: amd64
steps:
- name: dryrun
image: plugins/docker
settings:
build_args:
- BUILD_VERSION=${DRONE_TAG%-*}
dockerfile: Dockerfile
dry_run: true
password:
from_secret: docker_password
repo: xoxys/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/pull/**
- name: publish
image: plugins/docker
settings:
auto_tag: true
auto_tag_suffix: amd64
build_args:
- BUILD_VERSION=${DRONE_TAG%-*}
dockerfile: Dockerfile
password:
from_secret: docker_password
repo: xoxys/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/master
- refs/tags/**
- name: publish-gitea
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_token
base_url: https://gitea.rknet.org
note: CHANGELOG.md
overwrite: true
title: ${DRONE_TAG}
when:
ref:
- refs/tags/**
---
kind: pipeline
name: notifications
platform:
os: linux
arch: amd64
steps:
- name: manifest
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: manifest.tmpl
tags:
- ${DRONE_TAG}
- ${DRONE_TAG%-*}
- ${DRONE_TAG%.*}
- ${DRONE_TAG%%.*}
username:
from_secret: docker_username
when:
status:
- success
- name: readme
image: sheogorath/readme-to-dockerhub
environment:
DOCKERHUB_PASSWORD:
from_secret: docker_password
DOCKERHUB_REPO_NAME: ${DRONE_REPO_NAME}
DOCKERHUB_REPO_PREFIX: xoxys
DOCKERHUB_USERNAME:
from_secret: docker_username
README_PATH: README.md
SHORT_DESCRIPTION: Molecule - Automated Ansible roles testing
when:
status:
- success
- name: matrix
image: plugins/matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
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 }}"
username:
from_secret: matrix_username
when:
status:
- success
- failure
trigger:
ref:
- refs/heads/master
- refs/tags/**
status:
- success
- failure
depends_on:
- build-amd64
---
kind: signature
hmac: 461d7541c6d7b1b46499d8d391ae5f9145845aa41e71787e0a79fea27803e4d1
...

1
.gitignore vendored
View File

@ -1 +0,0 @@
CHANGELOG.md

View File

@ -1,47 +0,0 @@
---
version: "1.1"
versioning:
update-major: []
update-minor: [feat]
update-patch: [fix, perf, refactor, chore, test, ci, docs]
tag:
pattern: "v%d.%d.%d"
release-notes:
sections:
- name: Features
commit-types: [feat]
section-type: commits
- name: Bug Fixes
commit-types: [fix]
section-type: commits
- name: Performance Improvements
commit-types: [perf]
section-type: commits
- name: Code Refactoring
commit-types: [refactor]
section-type: commits
- name: Others
commit-types: [chore]
section-type: commits
- name: Testing
commit-types: [test]
section-type: commits
- name: CI Pipeline
commit-types: [ci]
section-type: commits
- name: Documentation
commit-types: [docs]
section-type: commits
- name: BREAKING CHANGES
section-type: breaking-changes
commit-message:
footer:
issue:
key: issue
add-value-prefix: "#"
issue:
regex: "#?[0-9]+"

View File

@ -1,6 +0,0 @@
---
default: True
MD013: False
MD041: False
MD004:
style: dash

View File

@ -1,2 +0,0 @@
*.tpl.md
LICENSE

View File

@ -1,69 +0,0 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: security-build
image: quay.io/thegeeklab/wp-docker-buildx:4
settings:
containerfile: Containerfile.multiarch
output: type=oci,dest=oci/${CI_REPO_NAME},tar=false
repo: thegeeklab/${CI_REPO_NAME}
- name: security-scan
image: ghcr.io/aquasecurity/trivy
commands:
- trivy -v
- trivy image --input oci/${CI_REPO_NAME}
environment:
TRIVY_EXIT_CODE: "1"
TRIVY_IGNORE_UNFIXED: "true"
TRIVY_NO_PROGRESS: "true"
TRIVY_SEVERITY: HIGH,CRITICAL
TRIVY_TIMEOUT: 1m
- name: publish-dockerhub
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container
settings:
auto_tag: true
containerfile: Containerfile.multiarch
password:
from_secret: docker_password
platforms:
- linux/amd64
- linux/arm64
provenance: false
repo: thegeeklab/${CI_REPO_NAME}
username:
from_secret: docker_username
when:
- event: [tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
- name: publish-quay
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container
settings:
auto_tag: true
containerfile: Containerfile.multiarch
password:
from_secret: quay_password
platforms:
- linux/amd64
- linux/arm64
provenance: false
registry: quay.io
repo: quay.io/thegeeklab/${CI_REPO_NAME}
username:
from_secret: quay_username
when:
- event: [tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}

View File

@ -1,25 +0,0 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: changelog
image: quay.io/thegeeklab/git-sv
commands:
- git sv current-version
- git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md
- cat CHANGELOG.md
- name: publish-gitea
image: quay.io/thegeeklab/wp-gitea-release
settings:
api_key:
from_secret: gitea_token
base_url: https://gitea.rknet.org
note: CHANGELOG.md
title: ${CI_COMMIT_TAG}
when:
- event: [tag]

View File

@ -1,62 +0,0 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: markdownlint
image: quay.io/thegeeklab/markdownlint-cli
group: test
commands:
- markdownlint 'README.md'
- name: spellcheck
image: quay.io/thegeeklab/alpine-tools
group: test
commands:
- spellchecker --files '_docs/**/*.md' 'README.md' -d .dictionary -p spell indefinite-article syntax-urls
environment:
FORCE_COLOR: "true"
- name: link-validation
image: docker.io/lycheeverse/lychee
group: test
commands:
- lychee --no-progress --format detailed README.md
- name: pushrm-dockerhub
image: docker.io/chko/docker-pushrm:1
secrets:
- source: docker_password
target: DOCKER_PASS
- source: docker_username
target: DOCKER_USER
environment:
PUSHRM_FILE: README.md
PUSHRM_SHORT: Custom image for Ansible Molecule test automation
PUSHRM_TARGET: thegeeklab/${CI_REPO_NAME}
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success]
- name: pushrm-quay
image: docker.io/chko/docker-pushrm:1
secrets:
- source: quay_token
target: APIKEY__QUAY_IO
environment:
PUSHRM_FILE: README.md
PUSHRM_TARGET: quay.io/thegeeklab/${CI_REPO_NAME}
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success]
depends_on:
- build-package
- build-container

View File

@ -1,26 +0,0 @@
---
when:
- event: [tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
runs_on: [success, failure]
steps:
- name: matrix
image: quay.io/thegeeklab/wp-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
when:
- status: [success, failure]
depends_on:
- docs

2
CHANGELOG.md Normal file
View File

@ -0,0 +1,2 @@
* ENHANCEMENT
* upstream version update

View File

@ -1,43 +0,0 @@
FROM docker.io/python:3.12-alpine@sha256:5365725a6cd59b72a927628fdda9965103e3dc671676c89ef3ed8b8b0e22e812
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.title="molecule"
LABEL org.opencontainers.image.url="https://gitea.rknet.org/container/molecule"
LABEL org.opencontainers.image.source="https://gitea.rknet.org/container/molecule"
LABEL org.opencontainers.image.documentation="https://gitea.rknet.org/container/molecule"
ARG ANSIBLE_VERSION
ARG MOLECULE_VERSION
# renovate: datasource=pypi depName=molecule
ENV MOLECULE_VERSION="${MOLECULE_VERSION:-24.2.1}"
# renovate: datasource=pypi depName=ansible
ENV ANSIBLE_VERSION="${ANSIBLE_VERSION:-9.5.1}"
ENV PY_COLORS=1
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ENV ANSIBLE_FORCE_COLOR=true
ENV USER=root
COPY overlay/ /
RUN apk add --update --no-cache --virtual .build-deps build-base libffi-dev musl-dev openssl-dev python3-dev cargo && \
apk add --update --no-cache git openssh-client && \
apk upgrade --no-cache libexpat && \
echo "Installing requirements ..." && \
pip install -qq --no-cache-dir --upgrade pip && \
pip install -qq --no-cache-dir boto boto3 botocore apache-libcloud hcloud \
flaky passlib pytest pytest-testinfra && \
echo "Installing ansible 'v$ANSIBLE_VERSION' ..." && \
pip install -qq --no-cache-dir ansible=="$ANSIBLE_VERSION" && \
echo "Installing molecule version 'v$MOLECULE_VERSION' ..." && \
pip install -qq --no-cache-dir molecule=="$MOLECULE_VERSION" molecule-plugins[docker] molecule_hetznercloud; \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
rm -rf /root/.cache/
USER root
CMD []
ENTRYPOINT ["/bin/molecule"]

46
Dockerfile Normal file
View File

@ -0,0 +1,46 @@
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"
ARG ANSIBLE_VERSION=2.9.0
ARG BUILD_VERSION=latest
ENV PY_COLORS=1 \
ANSIBLE_FORCE_COLOR=true \
USER=root \
PATH=/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin \
MOLECULE_VERSION="${BUILD_VERSION:-latest}"
COPY overlay/ /
RUN apk add --update --no-cache --virtual .build-deps gcc make libffi-dev musl-dev \
openssl-dev python3-dev && \
apk add --update --no-cache git openssh-client && \
# Required to fix hcloud dependency:
# hcloud 1.6.3 has requirement requests<2.23,>=2.20, but you'll have requests 2.23.0
echo "Installing ansible 'v$ANSIBLE_VERSION' ..." && \
pip install -qq --upgrade --no-cache-dir pip setuptools requests~=2.22.0 && \
pip install -qq --no-cache-dir ansible~="$ANSIBLE_VERSION" && \
echo "Installing requirements ..." && \
MOLECULE_VERSION="${MOLECULE_VERSION##v}" && \
MOLECULE_MAJOR="${MOLECULE_VERSION%%.*}" && \
pip install -qq --no-cache-dir -r /root/requirements.txt && \
if [ -z "${MOLECULE_MAJOR//[0-9]}" ] && [ -n "$MOLECULE_MAJOR" ]; then \
echo "Installing molecule version '$MOLECULE_VERSION' ..." && \
pip install -qq --no-cache-dir molecule~="$MOLECULE_VERSION"; \
else \
echo "Installing latest molecule ..." && \
pip install -qq --no-cache-dir molecule; \
fi && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
rm -rf /root/.cache/
USER root
CMD []
ENTRYPOINT ["/bin/molecule"]

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
Copyright (c) 2020 Robert Kaussow <mail@geeklabor.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,18 +1,10 @@
# molecule
# [molecule](https://gitea.rknet.org/docker/molecule)
Custom image for Ansible Molecule test automation
[![Build Status](https://img.shields.io/drone/build/docker/molecule?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/molecule)
[![Docker Hub](https://img.shields.io/badge/docker-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/xoxys/molecule)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/docker/molecule/src/branch/master/LICENSE)
<!-- spellchecker-disable -->
[![Build Status](https://ci.rknet.org/api/badges/container/molecule/status.svg)](https://ci.rknet.org/repos/container/molecule)
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/molecule)
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/molecule)
[![Source: Gitea](https://img.shields.io/badge/source-gitea-blue.svg?logo=gitea&logoColor=white)](https://gitea.rknet.org/container/molecule)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/container/molecule/src/branch/main/LICENSE)
<!-- spellchecker-enable -->
Custom container image to automate Ansible deployment tests with [Molecule](https://ansible.readthedocs.io/projects/molecule/).
Docker image to automate Ansible deployment tests with Molecule. The image was build to use with any docker based CI system.
## Environment variables
@ -30,12 +22,12 @@ MOLECULE_PLUGINS_DIR=$(pwd)/plugins
# If you have custom filters you can specify a git repo containing these files.
# Will be cloned to $MOLECULE_PLUGINS_DIR/filter
MOLECULE_CUSTOM_FILTERS_REPO=
# If the variable is set, the value is written to `ANSIBLE_VAULT_PASSWORD_FILE=/root/.vaultpasswd
and automatically passed to molecule.
MOLECULE_ANSIBLE_VAULT_PASSWORD=my_secret
```
## License
This project is licensed under the MIT License - see the [LICENSE](https://gitea.rknet.org/container/molecule/src/branch/main/LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](https://gitea.rknet.org/docker/molecule/src/branch/master/LICENSE) file for details.
## Maintainers and Contributors
[Robert Kaussow](https://gitea.rknet.org/xoxys)

15
manifest.tmpl Normal file
View File

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

View File

@ -1,5 +1,4 @@
#!/usr/bin/env sh
# shellcheck disable=2039,3040
set -eo pipefail
DIR=$(pwd)
@ -11,7 +10,7 @@ if [ -n "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
WORKDIR="${MOLECULE_LIBRARY_DIR}"
[ -d "$WORKDIR" ] && rm -rf "$WORKDIR"
mkdir -p "$WORKDIR"
git clone "$MOLECULE_CUSTOM_MODULES_REPO" "$WORKDIR" 2>/dev/null
git clone "$MOLECULE_CUSTOM_MODULES_REPO" "$WORKDIR" 2> /dev/null
fi
if [ -n "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
@ -19,14 +18,7 @@ if [ -n "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
printf "Cloning custom filters ...\n"
[ -d "$WORKDIR" ] && rm -rf "$WORKDIR"
mkdir -p "$WORKDIR"
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "$WORKDIR" 2>/dev/null
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "$WORKDIR" 2> /dev/null
fi
if [ -n "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" ]; then
printf "Write vault password file ...\n"
MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE=/root/.vaultpasswd
echo "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" >$MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE
exec env ANSIBLE_VAULT_PASSWORD_FILE=$MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE /usr/local/bin/molecule "$@"
else
exec /usr/local/bin/molecule "$@"
fi
exec /usr/local/bin/molecule "$@"

View File

@ -0,0 +1,15 @@
# linter
testinfra
flake8
yamllint
ansible-lint
# cloud provider deps
boto
boto3
botocore
apache-libcloud
hcloud
# misc
pycrypto

View File

@ -1,4 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>thegeeklab/renovate-presets:docker"]
}

View File

@ -1,6 +0,0 @@
---
allow-rules:
- id: private-key
path: .*/ansible/.*/site-packages/ansible_collections/(community|google|netapp)/.*\.py
- id: aws-secret-access-key
path: .*/ansible/.*/site-packages/ansible_collections/amazon/.*\.py

View File

@ -1,4 +0,0 @@
---
scan:
skip-files:
- /usr/local/bin/gomplate