-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
124 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: ubuntu2404-ansible-latest | ||
on: | ||
# yamllint disable-line rule:truthy | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'ubuntu2404-ansible-latest/**' | ||
pull_request: | ||
paths: | ||
- 'ubuntu2404-ansible-latest/**' | ||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dockerimage: | ||
- ubuntu2404-ansible | ||
platforms: | ||
- linux/amd64 | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Build and export to Docker | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ matrix.dockerimage }}-latest | ||
tags: docker-${{ matrix.dockerimage }}:test | ||
load: true | ||
platforms: ${{ matrix.platforms }} | ||
- | ||
name: Test | ||
run: | | ||
docker run --rm docker-${{ matrix.dockerimage }}:test | ||
- | ||
name: Login to ghcr.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
if: github.ref == 'refs/heads/master' | ||
- | ||
name: Build and push to ghcr.io | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ matrix.dockerimage }}-latest | ||
push: true | ||
tags: ghcr.io/dev-sec/docker-${{ matrix.dockerimage }}:latest | ||
platforms: ${{ matrix.platforms }} | ||
if: github.ref == 'refs/heads/master' | ||
- | ||
name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
if: github.ref == 'refs/heads/master' | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ matrix.dockerimage }}-latest | ||
push: true | ||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/docker-${{ matrix.dockerimage }}:latest | ||
platforms: ${{ matrix.platforms }} | ||
if: github.ref == 'refs/heads/master' |
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,42 @@ | ||
FROM ubuntu:24.04 | ||
LABEL maintainer="Sebastian Gumprich" | ||
|
||
# Install dependencies. | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
software-properties-common \ | ||
rsyslog systemd systemd-cron sudo \ | ||
&& rm -Rf /var/lib/apt/lists/* \ | ||
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ | ||
&& apt-get clean | ||
RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf | ||
|
||
# Install Ansible | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ansible \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \ | ||
&& apt-get clean | ||
|
||
# Install Ansible inventory file | ||
RUN mkdir /etc/ansible \ | ||
&& echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts | ||
|
||
# https://molecule.readthedocs.io/en/latest/examples.html#docker-with-non-privileged-user | ||
# Create `ansible` user with sudo permissions and membership in `DEPLOY_GROUP` | ||
# This template gets rendered using `loop: "{{ molecule_yml.platforms }}"`, so | ||
# each `item` is an element of platforms list from the molecule.yml file for this scenario. | ||
ENV ANSIBLE_USER=ansible DEPLOY_GROUP=deployer SUDO_GROUP=sudo | ||
RUN set -xe \ | ||
&& groupadd -r ${ANSIBLE_USER} \ | ||
&& groupadd -r ${DEPLOY_GROUP} \ | ||
&& useradd -m -g ${ANSIBLE_USER} ${ANSIBLE_USER} \ | ||
&& usermod -aG ${SUDO_GROUP} ${ANSIBLE_USER} \ | ||
&& usermod -aG ${DEPLOY_GROUP} ${ANSIBLE_USER} \ | ||
&& sed -i "/^%${SUDO_GROUP}/s/ALL\$/NOPASSWD:ALL/g" /etc/sudoers | ||
|
||
# delete file created by systemd that prevents login via ssh | ||
RUN rm -f /{var/run,etc,run}/nologin | ||
|
||
CMD [ "ansible-playbook", "--version" ] |