-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Ubuntu 21.04 LTS (Hirsute Hippo) Ansible Test Image | ||
|
||
[](https://github.com/buluma/ubuntu/actions/workflows/build-21.04.yml)   | ||
|
||
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/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |