Skip to content

Commit

Permalink
kinetic and rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
buluma committed Jun 12, 2022
1 parent b304e6d commit 40b0ffb
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-14.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/386,linux/arm/v7
push: true
tags: |
${{ github.repository }}:14.04, ${{ github.repository }}:trusty-20191217, ${{ github.repository }}:trusty
${{ github.repository }}:14.04, ${{ github.repository }}:trusty-20220612, ${{ github.repository }}:trusty
2 changes: 1 addition & 1 deletion .github/workflows/build-16.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:16.04, ${{ github.repository }}:xenial-20210804, ${{ github.repository }}:xenial
${{ github.repository }}:16.04, ${{ github.repository }}:xenial-20220612, ${{ github.repository }}:xenial
2 changes: 1 addition & 1 deletion .github/workflows/build-18.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:18.04, ${{ github.repository }}:bionic-20210930, ${{ github.repository }}:bionic
${{ github.repository }}:18.04, ${{ github.repository }}:bionic-20220612, ${{ github.repository }}:bionic
2 changes: 1 addition & 1 deletion .github/workflows/build-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ jobs:
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:20.04, ${{ github.repository }}:focal, ${{ github.repository }}:focal-20211006, ${{ github.repository }}:latest
${{ github.repository }}:20.04, ${{ github.repository }}:focal, ${{ github.repository }}:focal-20220612, ${{ github.repository }}:latest
2 changes: 1 addition & 1 deletion .github/workflows/build-21.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:21.04, ${{ github.repository }}:hirsute-20211107, ${{ github.repository }}:hirsute
${{ github.repository }}:21.04, ${{ github.repository }}:hirsute-20220612, ${{ github.repository }}:hirsute
2 changes: 1 addition & 1 deletion .github/workflows/build-21.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:impish, ${{ github.repository }}:21.10, ${{ github.repository }}:impish-20211102, ${{ github.repository }}:rolling
${{ github.repository }}:impish, ${{ github.repository }}:21.10, ${{ github.repository }}:impish-20220612
2 changes: 1 addition & 1 deletion .github/workflows/build-22.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:22.04, ${{ github.repository }}:jammy, ${{ github.repository }}:jammy-20211122, ${{ github.repository }}:devel
${{ github.repository }}:22.04, ${{ github.repository }}:jammy, ${{ github.repository }}:jammy-20220612, ${{ github.repository }}:latest, ${{ github.repository }}:rolling
73 changes: 73 additions & 0 deletions .github/workflows/build-22.10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: 22.10, devel

on:
pull_request:
push:
paths:
- 'ubuntu2210/**'
- '.github/workflows/build-22.10.yml'
schedule:
- cron: '50 1,4 * * *'
workflow_dispatch:

jobs:
# Test the image builds and works correctly.
test:
name: Test ubuntu2204
# runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2

- name: Test building image.
run: cd ubuntu2210 && docker build -t docker-ubuntu-22 .

- name: Run the built image.
run: docker run --name test-container -d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro docker-ubuntu-22

# - name: Verify Ansible is accessible in the built image.
# run: docker exec --tty test-container env TERM=xterm ansible --version

# If on master branch, build and release image.
release:
name: Release
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: buluma/[email protected]
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Login to GitHub Container Registry
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image.
uses: docker/build-push-action@v2
with:
context: ubuntu2210/
file: ubuntu2210/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository }}:22.10, ${{ github.repository }}:kinetic, ${{ github.repository }}:kinetic-20220612, ${{ github.repository }}:devel
55 changes: 55 additions & 0 deletions ubuntu2210/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM ubuntu:kinetic

LABEL maintainer="Michael Buluma"

ARG DEBIAN_FRONTEND=noninteractive

# ENV pip_packages "ansible"

# Install dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
build-essential \
locales \
libffi-dev \
libssl-dev \
libyaml-dev \
python3-dev \
python3-setuptools \
python3-pip \
python3-yaml \
software-properties-common \
rsyslog systemd systemd-cron sudo iproute2 \
&& apt-get clean \
&& rm -Rf /var/lib/apt/lists/* \
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man

# hadolint ignore=DL3009
RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf

# Fix potential UTF-8 errors with ansible-test.
RUN locale-gen en_US.UTF-8

# Install Ansible via Pip. Avoid use of cache directory with pip.
# RUN pip3 install --no-cache-dir $pip_packages

# hadolint ignore=DL3045
COPY initctl_faker .
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl

# Install Ansible inventory file.
# RUN mkdir -p /etc/ansible
# hadolint ignore=ShellCheck-SC2028
# 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 (https://github.com/ansible/molecule/issues/1104)
RUN rm -f /lib/systemd/system/systemd*udev* \
&& rm -f /lib/systemd/system/getty.target

VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]
CMD ["/lib/systemd/systemd"]

HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost/ || exit 1
38 changes: 38 additions & 0 deletions ubuntu2210/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ubuntu 21.04 LTS (Hirsute Hippo) Ansible Test Image

[![ubuntu2104](https://github.com/buluma/ubuntu/actions/workflows/build-21.04.yml/badge.svg?branch=main)](https://github.com/buluma/ubuntu/actions/workflows/build-21.04.yml) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/buluma/ubuntu/22.04) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/buluma/ubuntu/22.04)

Ubuntu 21.04 LTS (Hirsute Hippo) Docker container for Ansible playbook and role testing.

## Tags

- `latest`: Latest stable version of Ansible.

The latest tag is a lightweight image for basic validation of Ansible playbooks.

## How to Build

This image is built on Docker Hub automatically any time the upstream OS container is rebuilt, and any time a commit is made or merged to the `main` branch. But if you need to build the image on your own locally, do the following:

1. [Install Docker](https://docs.docker.com/install/).
2. `cd` into this directory.
3. Run `docker build -t ubuntu2104-ansible .`

## How to Use

1. [Install Docker](https://docs.docker.com/engine/installation/).
2. Pull this image from Docker Hub: `docker pull buluma/docker-ubuntu2104-ansible:latest` (or use the image you built earlier, e.g. `ubuntu2104-ansible:latest`).
3. Run a container from the image: `docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro buluma/docker-ubuntu2104-ansible:latest` (to test my Ansible roles, I add in a volume mounted from the current working directory with ``--volume=`pwd`:/etc/ansible/roles/role_under_test:ro``).
4. Use Ansible inside the container:
a. `docker exec --tty [container_id] env TERM=xterm ansible --version`
b. `docker exec --tty [container_id] env TERM=xterm ansible-playbook /path/to/ansible/playbook.yml --syntax-check`

## Notes

I use Docker to test my Ansible roles and playbooks on multiple OSes using CI tools like Jenkins and Travis. This container allows me to test roles and playbooks using Ansible running locally inside the container.

> **Important Note**: I use this image for testing in an isolated environment—not for production—and the settings and configuration used may not be suitable for a secure and performant production environment. Use on production servers/in the wild at your own risk!
## Author

Created in 2021 by [Michael Buluma](https://www.buluma.co.ke/).
23 changes: 23 additions & 0 deletions ubuntu2210/initctl_faker
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
ALIAS_CMD="$(echo "$0" | sed -e 's?/sbin/??')"

case "$ALIAS_CMD" in
start|stop|restart|reload|status)
exec service $1 $ALIAS_CMD
;;
esac

case "$1" in
list )
exec service --status-all
;;
reload-configuration )
exec service $2 restart
;;
start|stop|restart|reload|status)
exec service $2 $1
;;
\?)
exit 0
;;
esac

0 comments on commit 40b0ffb

Please sign in to comment.