1 Commits

Author SHA1 Message Date
778e90fab8 chore(deps): update docker.io/plugins/docker docker tag to v20.18.6
All checks were successful
continuous-integration/drone/push Build is passing
2024-12-25 05:00:47 +00:00
12 changed files with 365 additions and 284 deletions

298
.drone.yml Normal file
View File

@ -0,0 +1,298 @@
---
kind: pipeline
type: kubernetes
name: linter
clone:
disable: true
steps:
- name: clone
image: git.cryptic.systems/volker.raschek/git:1.4.0
- name: markdown lint
commands:
- markdownlint *.md
image: git.cryptic.systems/volker.raschek/markdownlint:0.43.0
resources:
limits:
cpu: 150
memory: 150M
- name: email-notification
environment:
SMTP_FROM_ADDRESS:
from_secret: smtp_from_address
SMTP_FROM_NAME:
from_secret: smtp_from_name
SMTP_HOST:
from_secret: smtp_host
SMTP_USERNAME:
from_secret: smtp_username
SMTP_PASSWORD:
from_secret: smtp_password
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
resources:
limits:
cpu: 150
memory: 150M
when:
status:
- changed
- failure
trigger:
event:
exclude:
- tag
---
kind: pipeline
type: docker
name: dry-run-amd64
clone:
disable: true
depends_on:
- linter
platform:
os: linux
arch: amd64
steps:
- name: clone
image: git.cryptic.systems/volker.raschek/git:1.4.0
- name: build
image: docker.io/plugins/docker:20.18.6
settings:
auto_tag: false
dockerfile: Dockerfile
dry_run: true
force_tag: true
no_cache: true
purge: true
mirror:
from_secret: docker_io_mirror
registry: git.cryptic.systems
repo: git.cryptic.systems/volker.raschek/ansible-archlinux
username:
from_secret: git_cryptic_systems_container_registry_user
password:
from_secret: git_cryptic_systems_container_registry_password
- name: email-notification
environment:
SMTP_FROM_ADDRESS:
from_secret: smtp_from_address
SMTP_FROM_NAME:
from_secret: smtp_from_name
SMTP_HOST:
from_secret: smtp_host
SMTP_USERNAME:
from_secret: smtp_username
SMTP_PASSWORD:
from_secret: smtp_password
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
when:
status:
- changed
- failure
trigger:
branch:
exclude:
- master
event:
- pull_request
- push
repo:
- volker.raschek/ansible-archlinux-docker
---
kind: pipeline
type: docker
name: latest-amd64
clone:
disable: true
depends_on:
- linter
platform:
os: linux
arch: amd64
steps:
- name: clone
image: git.cryptic.systems/volker.raschek/git:1.4.0
- name: build
image: docker.io/plugins/docker:20.18.6
settings:
auto_tag: false
dockerfile: Dockerfile
force_tag: true
no_cache: true
purge: true
mirror:
from_secret: docker_io_mirror
registry: git.cryptic.systems
repo: git.cryptic.systems/volker.raschek/ansible-archlinux
tags: latest-amd64
username:
from_secret: git_cryptic_systems_container_registry_user
password:
from_secret: git_cryptic_systems_container_registry_password
- name: email-notification
environment:
SMTP_FROM_ADDRESS:
from_secret: smtp_from_address
SMTP_FROM_NAME:
from_secret: smtp_from_name
SMTP_HOST:
from_secret: smtp_host
SMTP_USERNAME:
from_secret: smtp_username
SMTP_PASSWORD:
from_secret: smtp_password
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
when:
status:
- changed
- failure
trigger:
branch:
- master
event:
- cron
- push
repo:
- volker.raschek/ansible-archlinux-docker
---
kind: pipeline
type: kubernetes
name: latest-manifest
clone:
disable: true
depends_on:
- latest-amd64
# docker.io/plugins/manifest only for amd64 architectures available
node_selector:
kubernetes.io/os: linux
kubernetes.io/arch: amd64
steps:
- name: clone
image: git.cryptic.systems/volker.raschek/git:1.4.0
- name: build-manifest
image: docker.io/plugins/manifest:1.4.0
settings:
auto_tag: false
ignore_missing: true
spec: manifest.tmpl
username:
from_secret: git_cryptic_systems_container_registry_user
password:
from_secret: git_cryptic_systems_container_registry_password
- name: email-notification
environment:
SMTP_FROM_ADDRESS:
from_secret: smtp_from_address
SMTP_FROM_NAME:
from_secret: smtp_from_name
SMTP_HOST:
from_secret: smtp_host
SMTP_USERNAME:
from_secret: smtp_username
SMTP_PASSWORD:
from_secret: smtp_password
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
resources:
limits:
cpu: 150
memory: 150M
when:
status:
- changed
- failure
trigger:
branch:
- master
event:
- cron
- push
repo:
- volker.raschek/ansible-archlinux-docker
---
kind: pipeline
type: kubernetes
name: latest-sync
clone:
disable: true
depends_on:
- latest-manifest
steps:
- name: clone
image: git.cryptic.systems/volker.raschek/git:1.4.0
- name: latest-sync
commands:
- skopeo sync --all --src=docker --src-creds=$SRC_CRED_USERNAME:$SRC_CRED_PASSWORD --dest=docker --dest-creds=$DEST_CRED_USERNAME:$DEST_CRED_PASSWORD git.cryptic.systems/volker.raschek/ansible-archlinux docker.io/volkerraschek
environment:
SRC_CRED_USERNAME:
from_secret: git_cryptic_systems_container_registry_user
SRC_CRED_PASSWORD:
from_secret: git_cryptic_systems_container_registry_password
DEST_CRED_USERNAME:
from_secret: container_image_registry_user
DEST_CRED_PASSWORD:
from_secret: container_image_registry_password
image: quay.io/skopeo/stable:v1.17.0
- name: email-notification
environment:
SMTP_FROM_ADDRESS:
from_secret: smtp_from_address
SMTP_FROM_NAME:
from_secret: smtp_from_name
SMTP_HOST:
from_secret: smtp_host
SMTP_USERNAME:
from_secret: smtp_username
SMTP_PASSWORD:
from_secret: smtp_password
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
resources:
limits:
cpu: 150
memory: 150M
when:
status:
- changed
- failure
trigger:
branch:
- master
event:
- cron
- push
repo:
- volker.raschek/ansible-archlinux-docker

View File

@ -1,45 +0,0 @@
name: Build
on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- master
workflow_dispatch: {}
jobs:
build-arch-linux:
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4.2.2
- uses: docker/setup-qemu-action@v3.6.0
- uses: docker/setup-buildx-action@v3.11.1
- name: Build image
run: |
TAG=latest
docker buildx build \
--file Dockerfile.archlinux \
--tag git.cryptic.systems/volker.raschek/ansible:${TAG}-archlinux \
.
build-rocky-linux-8:
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4.2.2
- uses: docker/setup-qemu-action@v3.6.0
- uses: docker/setup-buildx-action@v3.11.1
- name: Build image
run: |
TAG=latest
docker buildx build \
--file Dockerfile.rockylinux8 \
--tag git.cryptic.systems/volker.raschek/ansible:${TAG}-rockylinux-8 \
.

View File

@ -1,22 +0,0 @@
name: 'Lint Markdown files'
on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- master
workflow_dispatch: {}
jobs:
markdown-lint:
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
with:
globs: '**/*.md'

View File

@ -1,77 +0,0 @@
name: Release
on:
push:
tags:
- "**"
jobs:
push-arch-linux:
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4.2.2
- uses: docker/setup-qemu-action@v3.6.0
- uses: docker/setup-buildx-action@v3.11.1
- uses: docker/login-action@v3.5.0
with:
registry: git.cryptic.systems
username: ${{ github.repository_owner }}
password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
- name: Build and push image
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
docker buildx build \
--file Dockerfile.archlinux \
--push \
--tag git.cryptic.systems/volker.raschek/ansible:${TAG}-archlinux \
.
push-rocky-linux-8:
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4.2.2
- uses: docker/setup-qemu-action@v3.6.0
- uses: docker/setup-buildx-action@v3.11.1
- uses: docker/login-action@v3.5.0
with:
registry: git.cryptic.systems
username: ${{ github.repository_owner }}
password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
- name: Build and push image
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
docker buildx build \
--file Dockerfile.rockylinux8 \
--push \
--tag git.cryptic.systems/volker.raschek/ansible:${TAG}-rockylinux-8 \
.
sync-to-hub-docker-io:
needs:
- push-arch-linux
- push-rocky-linux-8
runs-on: ubuntu-latest
steps:
- name: Copy images to docker.io
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
apt-get update --yes
apt-get install --yes skopeo
for suffix in archlinux rockylinux-8; do
skopeo copy \
--all \
--dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \
--dest-username ${{ secrets.DOCKER_IO_USERNAME }} \
--src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \
--src-username volker.raschek \
docker://git.cryptic.systems/volker.raschek/ansible:${TAG}-${suffix} \
docker://docker.io/volkerraschek/ansible:${TAG}-${suffix}
done

View File

@ -1,22 +0,0 @@
name: Update Docker Hub Description
on:
push:
branches:
- master
paths:
- README.md
workflow_dispatch: {}
jobs:
update-description-on-hub-docker-io:
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: peter-evans/dockerhub-description@v4.0.2
with:
username: ${{ secrets.DOCKER_IO_USERNAME }}
password: ${{ secrets.DOCKER_IO_PASSWORD }}
repository: volkerraschek/ansible
readme-filepath: README.md

View File

@ -45,17 +45,19 @@ MD012:
# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 120
line_length: 80
# Number of characters for headings
heading_line_length: 120
heading_line_length: 80
# Number of characters for code blocks
code_block_line_length: 120
code_block_line_length: 80
# Include code blocks
code_blocks: false
# Include tables
tables: false
# Include headings
headings: true
# Include headings
headers: true
# Strict length checking
strict: false
# Stern length checking
@ -68,6 +70,11 @@ MD022:
# Blank lines below heading
lines_below: 1
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024:
# Only check sibling headings
allow_different_nesting: true
# MD025/single-title/single-h1 - Multiple top-level headings in the same document
MD025:
# Heading level
@ -122,6 +129,7 @@ MD041:
MD044:
# List of proper names
names: []
# - some-thing
# Include code blocks
code_blocks: false
@ -133,4 +141,4 @@ MD046:
# MD048/code-fence-style - Code fence style
MD048:
# Code fence syle
style: "backtick"
style: "backtick"

View File

@ -9,8 +9,6 @@ RUN pacman --sync --sysupgrade --refresh --noconfirm && \
openssl \
libyaml \
python \
python-boto3 \
python-botocore \
python-setuptools \
python-pip \
python-pytest \
@ -33,7 +31,7 @@ RUN locale-gen en_US.UTF-8
# Install Ansible inventory file
RUN mkdir --parents /etc/ansible
RUN echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
# Remove unnecessary getty and udev targets that result in high CPU usage when
# using multiple containers with molecule
@ -42,3 +40,4 @@ RUN rm --recursive --force /lib/systemd/system/systemd*udev* && \
rm --recursive --force /lib/systemd/system/getty.target
VOLUME [ "/sys/fs/cgroup", "/tmp", "/run"]
CMD [ "/lib/systemd/systemd" ]

View File

@ -1,31 +0,0 @@
FROM docker.io/library/rockylinux:8
RUN dnf update --assumeyes && \
dnf install --assumeyes bash-completion sudo && \
dnf install --assumeyes epel-release && \
dnf install --assumeyes ansible && \
dnf remove --assumeyes epel-release && \
dnf install --assumeyes 'dnf-command(config-manager)' && \
dnf config-manager --set-enabled ha && \
dnf install --assumeyes python3-boto3 python3-botocore && \
dnf clean all
# We must change python to 3.12 (default 3.6), to be compliant with ansible-core. Furthermore, we must upgrade pip to
# latest version. Otherwise is still used pip for python 3.6. At least, we install boto3, which is required for the aws
# dynamic inventory manually, because the official python-boto3 package is for python 3.6.
RUN alternatives --set python3 /usr/bin/python3.12 && \
curl --fail --silent --location https://bootstrap.pypa.io/get-pip.py --output get-pip.py && \
python3 get-pip.py && \
pip install boto3
# Create default ansible inventory file
RUN mkdir --parents /etc/ansible
RUN echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
# Remove unnecessary getty and udev targets that result in high CPU usage when
# using multiple containers with molecule
# (https://github.com/ansible/molecule/issues/1104)
RUN rm --recursive --force /lib/systemd/system/systemd*udev* && \
rm --recursive --force /lib/systemd/system/getty.target
VOLUME [ "/sys/fs/cgroup", "/tmp", "/run"]

View File

@ -3,71 +3,41 @@
# container runtime. This is needed to start and run a container image.
CONTAINER_RUNTIME?=$(shell which podman)
# ArchLinux
ANSIBLE_ARCH_IMAGE_REGISTRY_HOST?=git.cryptic.systems
ANSIBLE_ARCH_IMAGE_REGISTRY_USER?=volker.raschek
ANSIBLE_ARCH_IMAGE_NAMESPACE?=${ANSIBLE_ARCH_IMAGE_REGISTRY_USER}
ANSIBLE_ARCH_IMAGE_REPOSITORY:=ansible
ANSIBLE_ARCH_IMAGE_VERSION?=latest
ANSIBLE_ARCH_IMAGE_VERSION_SUFFIX=arch-linux
ANSIBLE_ARCH_IMAGE_FULLY_QUALIFIED=${ANSIBLE_ARCH_IMAGE_REGISTRY_HOST}/${ANSIBLE_ARCH_IMAGE_NAMESPACE}/${ANSIBLE_ARCH_IMAGE_REPOSITORY}:${ANSIBLE_ARCH_IMAGE_VERSION}-${ANSIBLE_ARCH_IMAGE_VERSION_SUFFIX}
# CONTAINER_IMAGE
# Defines the name of the new container to be built using several variables.
BUILD_IMAGE_REGISTRY_HOST:=git.cryptic.systems
BUILD_IMAGE_REGISTRY_USER:=volker.raschek
BUILD_IMAGE_NAMESPACE?=${BUILD_IMAGE_REGISTRY_USER}
BUILD_IMAGE_REPOSITORY:=ansible-archlinux
BUILD_IMAGE_VERSION?=latest
BUILD_IMAGE_FULLY_QUALIFIED=${BUILD_IMAGE_REGISTRY_HOST}/${BUILD_IMAGE_NAMESPACE}/${BUILD_IMAGE_REPOSITORY}:${BUILD_IMAGE_VERSION}
BUILD_IMAGE_UNQUALIFIED=${BUILD_IMAGE_NAMESPACE}/${BUILD_IMAGE_REPOSITORY}:${BUILD_IMAGE_VERSION}
# RockyLinux8
ANSIBLE_RL8_IMAGE_REGISTRY_HOST?=git.cryptic.systems
ANSIBLE_RL8_IMAGE_REGISTRY_USER?=volker.raschek
ANSIBLE_RL8_IMAGE_NAMESPACE?=${ANSIBLE_RL8_IMAGE_REGISTRY_USER}
ANSIBLE_RL8_IMAGE_REPOSITORY:=ansible
ANSIBLE_RL8_IMAGE_VERSION?=latest
ANSIBLE_RL8_IMAGE_VERSION_SUFFIX=rockylinux-8
ANSIBLE_RL8_IMAGE_FULLY_QUALIFIED=${ANSIBLE_RL8_IMAGE_REGISTRY_HOST}/${ANSIBLE_RL8_IMAGE_NAMESPACE}/${ANSIBLE_RL8_IMAGE_REPOSITORY}:${ANSIBLE_RL8_IMAGE_VERSION}-${ANSIBLE_RL8_IMAGE_VERSION_SUFFIX}
# BUILD ANSIBLE ARCHLINUX CONTAINER IMAGE
# BUILD CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/build/arch-linux
container-image/build/arch-linux:
PHONY:=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--file Dockerfile.archlinux \
--file Dockerfile \
--no-cache \
--pull \
--tag ${ANSIBLE_ARCH_IMAGE_FULLY_QUALIFIED} \
--tag ${BUILD_IMAGE_FULLY_QUALIFIED} \
--tag ${BUILD_IMAGE_UNQUALIFIED} \
.
# DELETE ANSIBLE ARCHLINUX CONTAINER IMAGE
# DELETE CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/delete/arch-linux
container-image/delete/arch-linux:
- ${CONTAINER_RUNTIME} image rm ${ANSIBLE_ARCH_IMAGE_FULLY_QUALIFIED}
PHONY:=container-image/delete
container-image/delete:
- ${CONTAINER_RUNTIME} image rm ${BUILD_IMAGE_FULLY_QUALIFIED} ${BUILD_IMAGE_UNQUALIFIED}
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULLY_QUALIFIED}
# PUSH ANSIBLE ARCHLINUX CONTAINER IMAGE
# PUSH CONTAINER IMAGE
# ==============================================================================
PHONY+=container-image/push/arch-linux
container-image/push/arch-linux:
echo ${ANSIBLE_ARCH_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${ANSIBLE_ARCH_IMAGE_REGISTRY_HOST} --username ${ANSIBLE_ARCH_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${ANSIBLE_ARCH_IMAGE_FULLY_QUALIFIED}
# BUILD ANSIBLE RL8 CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/build/rocky-linux-8
container-image/build/rocky-linux-8:
${CONTAINER_RUNTIME} build \
--file Dockerfile.rockylinux8 \
--no-cache \
--pull \
--tag ${ANSIBLE_RL8_IMAGE_FULLY_QUALIFIED} \
.
# DELETE ANSIBLE RL8 CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/delete/rocky-linux-8
container-image/delete/rocky-linux-8:
- ${CONTAINER_RUNTIME} image rm ${ANSIBLE_RL8_IMAGE_FULLY_QUALIFIED}
# PUSH ANSIBLE RL8 CONTAINER IMAGE
# ==============================================================================
PHONY+=container-image/push/rocky-linux-8
container-image/push/rocky-linux-8:
echo ${ANSIBLE_ARCH_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${ANSIBLE_ARCH_IMAGE_REGISTRY_HOST} --username ${ANSIBLE_ARCH_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${ANSIBLE_ARCH_IMAGE_FULLY_QUALIFIED}
PHONY+=container-image/push
container-image/push:
echo ${BUILD_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${BUILD_IMAGE_REGISTRY_HOST} --username ${BUILD_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${BUILD_IMAGE_FULLY_QUALIFIED}
# PHONY
# ==============================================================================

View File

@ -1,21 +1,4 @@
# ansible
# ansible-archlinux-docker
[![Build Status](https://drone.cryptic.systems/api/badges/volker.raschek/ansible-archlinux-docker/status.svg)](https://drone.cryptic.systems/volker.raschek/ansible-archlinux-docker)
[![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/ansible-archlinux)](https://hub.docker.com/r/volkerraschek/ansible-archlinux)
This container image can be used to execute ansible. It contains the latest versions of ansible-core, ansible-lint and
python-boto3 to interact with AWS dynamic inventory.
Here is an example. The environment variables as well as the path to the playbook and inventory must of course be
adapted to your own needs.
```bash
docker run \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN \
--rm \
--volume $(pwd):$(pwd) \
--workdir $(pwd) \
git.cryptic.systems/volker.raschek/ansible:latest \
bash -c "ansible-galaxy install -r requirements.yaml && ansible-playbook -i inventories/demo.aws_ec2.yaml aws.yaml"
```

14
manifest.tmpl Normal file
View File

@ -0,0 +1,14 @@
image: git.cryptic.systems/volker.raschek/ansible-archlinux:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
- "latest"
{{/if}}
manifests:
-
image: git.cryptic.systems/volker.raschek/ansible-archlinux:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64
platform:
architecture: amd64
os: linux

View File

@ -1,9 +1,15 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>volker.raschek/renovate-config:default#master",
"local>volker.raschek/renovate-config:container#master",
"local>volker.raschek/renovate-config:actions#master",
"local>volker.raschek/renovate-config:regexp#master"
]
"assignees": [ "volker.raschek" ],
"labels": [ "renovate" ],
"packageRules": [
{
"addLabels": [ "renovate/droneci", "renovate/automerge" ],
"automerge": true,
"matchManagers": "droneci",
"matchUpdateTypes": [ "minor", "patch"]
}
],
"rebaseLabel": "renovate/rebase",
"rebaseWhen": "behind-base-branch"
}