diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000..49a851a Binary files /dev/null and b/.github/.DS_Store differ diff --git a/.github/workflows/.DS_Store b/.github/workflows/.DS_Store new file mode 100644 index 0000000..1a77fd3 Binary files /dev/null and b/.github/workflows/.DS_Store differ diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..1542bf0 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,41 @@ +name: Docker Image CI +on: + push: + branches-ignore: + - "master" +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-20.04 #ubuntu-latest + - os: ubuntu-18.04 + steps: + # Checkout + - uses: actions/checkout@v2 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + # Verbose + - name: Print full context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Print branch and repository + run: echo "Branch = ${GITHUB_REF##*/} | Repository = ${GITHUB_REPOSITORY#*/}" + # Linting + - name: Lint Dockerfile + uses: github/super-linter@v4 + env: + #VALIDATE_ALL_CODEBASE: false + #VALIDATE_DOCKERFILE: true + VALIDATE_MARKDOWN: false + DEFAULT_BRANCH: ${{ github.ref }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Build + - name: Build the Docker image + run: docker build . --file Dockerfile --tag ${GITHUB_REPOSITORY#*/}:"${GITHUB_REF##*/}" + # Inspect + - name: Inspect image + run: docker image inspect ${GITHUB_REPOSITORY#*/}:"${GITHUB_REF##*/}" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0201cfd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release CI +on: + push: + branches: + - master +jobs: + Create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.2.0 + # Verbose + - name: Print full context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Print release name + env: + SUPPORTED_IMAGE: ${{ github.event.head_commit.message }} + run: echo "$SUPPORTED_IMAGE" + # # Docker Hub Login + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # Docker Hub Push + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ github.repository }}:${{ github.event.head_commit.message }} + # Verbose + - name: Print image digest + run: echo ${{ steps.docker_build.outputs.digest }} + # Create Release + - uses: ncipollo/release-action@v1 + with: + tag: ${{ github.event.head_commit.message }} + token: ${{ secrets.G_TOKEN }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c4abf25 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM ubuntu:20.04 +LABEL author="Hamza Hedhly" +LABEL version="Ubuntu 20.04 (Focal Fossa)" +LABEL documentation="https://github.com/senjoux" +# Supported Ansible releases: +# - 4.0 (default) +# - 3.0 +# - 2.10 +# see releases https://docs.ansible.com/ansible/devel/roadmap/ansible_roadmap_index.html +ENV ANSIBLE_VERSION=4.0.0 +# if none provided an "ansible" user will be created +ENV ANSIBLE_USER=ansible +# Python3-pip version +ENV PYTHON3_PIP_VERSION=20.0.2-5ubuntu1.5 + +RUN apt-get update --no-install-recommends -y \ + # prepare user + && adduser $ANSIBLE_USER \ + && echo "$ANSIBLE_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + # install Ansible + && apt-get install --no-install-recommends python3-pip=$PYTHON3_PIP_VERSION -y \ + && rm -rf /var/lib/apt/lists/*\ + && python3.8 -m pip install --no-cache-dir ansible==$ANSIBLE_VERSION \ + # other + && echo "export PS1='[\u@\h:\w] $ '" >> /home/$ANSIBLE_USER/.bashrc \ + # self + && ansible --version \ + && python3.8 -m pip list + +ENTRYPOINT ["/bin/bash","-c"] +CMD ["su $ANSIBLE_USER"] \ No newline at end of file diff --git a/README-Resources/.DS_Store b/README-Resources/.DS_Store new file mode 100644 index 0000000..9cf6a59 Binary files /dev/null and b/README-Resources/.DS_Store differ diff --git a/README-Resources/ansible_logo_icon.png b/README-Resources/ansible_logo_icon.png new file mode 100644 index 0000000..9db1edd Binary files /dev/null and b/README-Resources/ansible_logo_icon.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..7aa63e9 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +Ansible Logo + +# Docker-Ansible +[![CI][badge-gh-actions]][link-gh-actions] + +## Features +- Ansible control Docker image. +- Custom Ubuntu user creation + +## OS support +| OS | Version | +|------|---------| +| Ubuntu | 20.04 (Focal Fossa) | + +## Ansible releases support: +| Release | +|------| +| 4.0 | +| 3.0 | +| 2.10 | + +## Environment variables + +| Name | Version | default | +|------|---------|---------| +| `ANSIBLE_VERSION` | Ansible version. | 4.0.0 | +| `ANSIBLE_USER` | Custom Ubuntu user name. | ansible | +| `PYTHON3_PIP_VERSION` | Version of the "python3-pip" module to be used for Ansible installation. | 20.0.2-5ubuntu1.5 | + +## Usage +- Build image +``` +docker build -t ansible_control: . +``` +- Run & access container +``` +docker build -t ansible_control: . +``` + + +This project was created by [Hamza Hedhly](https://de.linkedin.com/in/hedhly). + +[badge-gh-actions]: https://github.com/senjoux/docker_ansible/actions/workflows/release.yml/badge.svg +[link-gh-actions]: https://github.com/senjoux/docker_ansible/actions/workflows/release.yml \ No newline at end of file