From 0d3c13fa0be0065d9bdb012886051a2385eb9870 Mon Sep 17 00:00:00 2001 From: thehedhly Date: Sun, 21 Jan 2024 18:13:01 +0100 Subject: [PATCH] Update Readme - Cleanup Dockerfile --- Dockerfile | 12 ++-------- README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile index db748f2..2b0a32c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,9 @@ ARG PYCMD="/usr/local/bin/python3.11" ARG SYS_ZONEINFO="Europe/Berlin" ARG ANSIBLE_HOME="/usr/share/ansible" ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS="-v" -ARG ANSIBLE_GALAXY_CLI_ROLE_OPTS="" -ARG ANSIBLE_INSTALL_REFS="" +ARG ANSIBLE_GALAXY_CLI_ROLE_OPTS="-v" +ARG ANSIBLE_INSTALL_REFS="ansible-core" # ARG ANSIBLE_INSTALL_REFS="ansible-core==2.16.0" -# ARG ANSIBLE_INSTALL_REFS="ansible-core" # ARG ANSIBLE_INSTALL_REFS="ansible==9" # ARG ANSIBLE_INSTALL_REFS="ansible" ARG ANSIBLE_USER="thehedhly" @@ -39,16 +38,9 @@ RUN ansible-galaxy role install "$ANSIBLE_GALAXY_CLI_ROLE_OPTS" -r requirements. # Final build stage FROM base as final -# LABEL org.opencontainers.image.created="date and time on which the image was built (string, date-time as defined by RFC 3339)" -# LABEL org.opencontainers.image.authors="https://github.com/thehedhly" -# LABEL org.opencontainers.image.url="https://hub.docker.com/repository/docker/thehedhly/ansible" -# LABEL org.opencontainers.image.source="https://github.com/thehedhly/ansible-docker" -# TODO Update according to ANSIBLE_INSTALL_REFS -# LABEL org.opencontainers.image.version="2.16.0" ARG ANSIBLE_HOME ARG ANSIBLE_USER ENV ANSIBLE_CONFIG "/home/$ANSIBLE_USER/.ansible.cfg" -# ENV ANSIBLE_HOME = $XANSIBLE_HOME COPY --from=galaxy $ANSIBLE_HOME $ANSIBLE_HOME diff --git a/README.md b/README.md new file mode 100644 index 0000000..a86276a --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +Ansible Logo + +# ansible-docker +![Build](https://github.com/thehedhly/ansible-docker/actions/workflows/ci.yml/badge.svg?branch=dev) +![Docker build](https://github.com/thehedhly/ansible-docker/actions/workflows/linter.yml/badge.svg?branch=dev) + +## Features +- Builds a [python](https://hub.docker.com/_/python) based __ansible__ docker __image__. + +## Ansible: +In accordance with both ansible community projects, __ansible community package__ and __ansible-core__, this project builds two seperate images as follows: + +| Ansible project | Supported versions | DockerHub Image | +|-----------------|----------|-------| +| ansible community package | | [thehedhly/ansible](https://hub.docker.com/repository/docker/thehedhly/ansible) | +| ansible-core | | [thehedhly/ansible-core](https://hub.docker.com/repository/docker/thehedhly/ansible-core) | + +## Build arguments +| Name | description | default | +|------|---------|---------| +| `BASE_IMAGE` | Base docker image. | python:3.11.7-slim | +| `PYCMD` | Python binary location.
:information_source: See also `BASE_IMAGE` | /usr/local/bin/python3.11 | +| `SYS_ZONEINFO` | System time zone. | Europe/Berlin | +| `ANSIBLE_INSTALL_REFS` | Ansible installation package.
You can install a specific version of a ansible community package or ansible-core, e.g.:
| ansible-core | +| `ANSIBLE_HOME` | Ansible home where the build's extra (optional) ansible roles/collections are installed.
See [Ansible requirements.yml](requirements.yml) | /usr/share/ansible | +| `ANSIBLE_GALAXY_CLI_COLLECTION_OPTS` | Build's CLI options for installing ansible collection.
Check [ansible-galaxy]() cli documentation for more details.| -v | +| `ANSIBLE_GALAXY_CLI_ROLE_OPTS` | Build's CLI options for installing ansible roles.
Check [ansible-galaxy]() cli documentation for more details. | -v | +| `ANSIBLE_USER` | User to set for ansible image. A home directory is setup for the provided user. The default [ansible configuration file](ansible.cfg) for the user is located in his home driectory. | thehedhly | + + +## Usage +### Build +`ansible-core` +``` +docker build -t ansible-core . +``` +``` +docker build --build-arg ANSIBLE_INSTALL_REFS=ansible-core== -t ansible-core: . +``` +`ansible community package` +``` +docker build --build-arg ANSIBLE_INSTALL_REFS=ansible -t ansible . +``` +``` +docker build --build-arg ANSIBLE_INSTALL_REFS=ansible== -t ansible: . +``` +#### Run +`ansible-core` +``` +docker run --rm -it ansible-core bash +``` +``` +docker run --rm -it ansible-core: bash +``` +``` +docker run --rm -it --mount type=bind,source=/home//,target=/opt/ --mount type=bind,source=/home//.ssh,target=/home//.ssh,readonly > bash +``` +`ansible community package` +``` +docker run --rm -it ansible bash +``` +``` +docker run --rm -it ansible: bash +``` +``` +docker run --rm -it --mount type=bind,source=/home//,target=/opt/ --mount type=bind,source=/home//.ssh,target=/home//.ssh,readonly > bash +``` + +This project was created by [H.Hedhly](https://hedhly.com).