• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language Makefile
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Alpine-based multistage-build version of Ansible for reproducible usage in CI

Docker image for ansible

Tag Docker License

lint build nightly

All #awesome-ci Docker images

ansible-lint ansible awesome-ci bandit black checkmake eslint file-lint gofmt goimports golint jsonlint kubeval linkcheck mypy php-cs-fixer phpcbf phpcs phplint pycodestyle pydocstyle pylint terraform-docs terragrunt-fmt terragrunt yamlfmt yamllint

View Dockerfiles on GitHub.

Available Architectures: amd64, arm64

Tiny Alpine-based multistage-build dockerized version of Ansible[1] in many different flavours. It comes with Mitogen[2] to speed up your runs by up to 600%[3][4] (see Examples). The image is built nightly against multiple stable versions and pushed to Dockerhub.

🐳 Available Docker image versions

This repository provides many different Ansible flavours (each flavour also divided into different Ansible versions).

The following tree shows how the different flavours derive from each other (each child has all the tools and features of its parent plus its own additions).

       base                    #docker-tag:  :latest
         |                                   :<version>
         |
       tools                   #docker-tag:  :latest-tools
      /  |  \                                :<version>-tools
     /   |   \
infra  azure  aws              #docker-tag:  :latest-infra     :latest-azure     :latest-aws
               |                             :<version>-infra  :<version>-azure  :<version>-aws
               |
             awsk8s            #docker-tag:  :latest-awsk8s
              /  \                           :<version>-awsk8s
             /    \
        awskops  awshelm       #docker-tag   :latest-awskops     :latest-awshelm
                                             :<version>-awskops  :<version>-awshelm

<version> refers to the latest[1], patch-level version of Ansible. E.g.: 2.9, 2.10, 2.11, ...
[1]: latest as docker images are (re)built every night via CI against the latest available patch level version of Ansible

The following table shows a quick overview of provided libraries and tools for each flavour. For more details see further down below.

Flavour Based on Additional Python libs Additional binaries
base - cffi, cryptography, Jinja2, junit-xml, lxml, paramiko, PyYAML -
tools base dnspython, JMESPath, mitogen bash, git, gpg, jq, ssh, yq
infra tools docker, docker-compose, jsondiff, netaddr, pexpect, psycopg2, pyldap, pypsexec, pymongo, PyMySQL, pywinrm, smbprotocol rsync, sshpass
azure tools azure-* az
aws tools awscli, botocore, boto, boto3 aws, aws-iam-authenticator
awsk8s aws openshift kubectl, oc
awskops awsk8s - kops
awshelm awsk8s - helm

🔁 Rolling releases

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Ansible base

The following Ansible Docker images are as small as possible and only contain Ansible itself.

Docker Tag Git Ref Ansible Available Architectures
latest master latest amd64, arm64
2.13 master 2.13.x amd64, arm64
2.12 master 2.12.x amd64, arm64
2.11 master 2.11.x amd64, arm64
2.10 master 2.10.x amd64, arm64
2.9 master 2.9.x amd64, arm64
2.8 master 2.8.x amd64, arm64

Ansible tools

The following Ansible Docker images contain everything from Ansible base and additionally: bash, git, gpg, jq, ssh and dnspython and Ansible mitogen strategy plugin (see Examples).

Docker Tag Git Ref Ansible Available Architectures
latest-tools master latest amd64, arm64
2.13-tools master 2.13.x amd64, arm64
2.12-tools master 2.12.x amd64, arm64
2.11-tools master 2.11.x amd64, arm64
2.10-tools master 2.10.x amd64, arm64
2.9-tools master 2.9.x amd64, arm64
2.8-tools master 2.8.x amd64, arm64

Ansible azure

The following Ansible Docker images contain everything from Ansible tools and additionally: azure.

Docker Tag Git Ref Ansible Available Architectures
latest-azure master latest amd64, arm64
2.13-azure master 2.13.x amd64, arm64
2.12-azure master 2.12.x amd64, arm64
2.11-azure master 2.11.x amd64, arm64
2.10-azure master 2.10.x amd64, arm64
2.9-azure master 2.9.x amd64, arm64
2.8-azure master 2.8.x amd64, arm64

Ansible aws

The following Ansible Docker images contain everything from Ansible tools and additionally: aws-cli, boto, boto3 and botocore.

Docker Tag Git Ref Ansible Available Architectures
latest-aws master latest amd64, arm64
2.13-aws master 2.13.x amd64, arm64
2.12-aws master 2.12.x amd64, arm64
2.11-aws master 2.11.x amd64, arm64
2.10-aws master 2.10.x amd64, arm64
2.9-aws master 2.9.x amd64, arm64
2.8-aws master 2.8.x amd64, arm64

Ansible awsk8s

The following Ansible Docker images contain everything from Ansible aws and additionally: openshift and kubectl.

Docker Tag Git Ref Ansible Available Architectures
latest-awsk8s master latest amd64, arm64
2.13-awsk8s master 2.13.x amd64, arm64
2.12-awsk8s master 2.12.x amd64, arm64
2.11-awsk8s master 2.11.x amd64, arm64
2.10-awsk8s master 2.10.x amd64, arm64
2.9-awsk8s master 2.9.x amd64, arm64
2.8-awsk8s master 2.8.x amd64, arm64

Ansible awskops

The following Ansible Docker images contain everything from Ansible awsk8s and additionally: kops in its latest patch level version.

https://github.com/kubernetes/kops/releases

Docker Tag Git Ref Ansible Kops Available Architectures
latest-awskops1.25 master latest 1.25.x amd64, arm64
2.13-awskops1.25 master 2.13.x 1.25.x amd64, arm64
2.12-awskops1.25 master 2.12.x 1.25.x amd64, arm64
2.11-awskops1.25 master 2.11.x 1.25.x amd64, arm64
2.10-awskops1.25 master 2.10.x 1.25.x amd64, arm64
2.9-awskops1.25 master 2.9.x 1.25.x amd64, arm64
2.8-awskops1.25 master 2.8.x 1.25.x amd64, arm64
latest-awskops1.24 master latest 1.24.x amd64, arm64
2.13-awskops1.24 master 2.13.x 1.24.x amd64, arm64
2.12-awskops1.24 master 2.12.x 1.24.x amd64, arm64
2.11-awskops1.24 master 2.11.x 1.24.x amd64, arm64
2.10-awskops1.24 master 2.10.x 1.24.x amd64, arm64
2.9-awskops1.24 master 2.9.x 1.24.x amd64, arm64
2.8-awskops1.24 master 2.8.x 1.24.x amd64, arm64
latest-awskops1.23 master latest 1.23.x amd64, arm64
2.13-awskops1.23 master 2.13.x 1.23.x amd64, arm64
2.12-awskops1.23 master 2.12.x 1.23.x amd64, arm64
2.11-awskops1.23 master 2.11.x 1.23.x amd64, arm64
2.10-awskops1.23 master 2.10.x 1.23.x amd64, arm64
2.9-awskops1.23 master 2.9.x 1.23.x amd64, arm64
2.8-awskops1.23 master 2.8.x 1.23.x amd64, arm64
latest-awskops1.22 master latest 1.22.x amd64, arm64
2.13-awskops1.22 master 2.13.x 1.22.x amd64, arm64
2.12-awskops1.22 master 2.12.x 1.22.x amd64, arm64
2.11-awskops1.22 master 2.11.x 1.22.x amd64, arm64
2.10-awskops1.22 master 2.10.x 1.22.x amd64, arm64
2.9-awskops1.22 master 2.9.x 1.22.x amd64, arm64
2.8-awskops1.22 master 2.8.x 1.22.x amd64, arm64
latest-awskops1.21 master latest 1.21.x amd64, arm64
2.13-awskops1.21 master 2.13.x 1.21.x amd64, arm64
2.12-awskops1.21 master 2.12.x 1.21.x amd64, arm64
2.11-awskops1.21 master 2.11.x 1.21.x amd64, arm64
2.10-awskops1.21 master 2.10.x 1.21.x amd64, arm64
2.9-awskops1.21 master 2.9.x 1.21.x amd64, arm64
2.8-awskops1.21 master 2.8.x 1.21.x amd64, arm64
latest-awskops1.20 master latest 1.20.x amd64, arm64
2.13-awskops1.20 master 2.13.x 1.20.x amd64, arm64
2.12-awskops1.20 master 2.12.x 1.20.x amd64, arm64
2.11-awskops1.20 master 2.11.x 1.20.x amd64, arm64
2.10-awskops1.20 master 2.10.x 1.20.x amd64, arm64
2.9-awskops1.20 master 2.9.x 1.20.x amd64, arm64
2.8-awskops1.20 master 2.8.x 1.20.x amd64, arm64
latest-awskops1.19 master latest 1.19.x amd64, arm64
2.13-awskops1.19 master 2.13.x 1.19.x amd64, arm64
2.12-awskops1.19 master 2.12.x 1.19.x amd64, arm64
2.11-awskops1.19 master 2.11.x 1.19.x amd64, arm64
2.10-awskops1.19 master 2.10.x 1.19.x amd64, arm64
2.9-awskops1.19 master 2.9.x 1.19.x amd64, arm64
2.8-awskops1.19 master 2.8.x 1.19.x amd64, arm64

Ansible awshelm

The following Ansible Docker images contain everything from Ansible awsk8s and additionally: helm in its latest patch level version.

https://github.com/helm/helm/releases

Docker Tag Git Ref Ansible Helm Available Architectures
latest-awshelm3.11 master latest 3.11.x amd64, arm64
2.13-awshelm3.11 master 2.13.x 3.11.x amd64, arm64
2.12-awshelm3.11 master 2.12.x 3.11.x amd64, arm64
2.11-awshelm3.11 master 2.11.x 3.11.x amd64, arm64
2.10-awshelm3.11 master 2.10.x 3.11.x amd64, arm64
2.9-awshelm3.11 master 2.9.x 3.11.x amd64, arm64
2.8-awshelm3.11 master 2.8.x 3.11.x amd64, arm64
latest-awshelm3.10 master latest 3.10.x amd64, arm64
2.13-awshelm3.10 master 2.13.x 3.10.x amd64, arm64
2.12-awshelm3.10 master 2.12.x 3.10.x amd64, arm64
2.11-awshelm3.10 master 2.11.x 3.10.x amd64, arm64
2.10-awshelm3.10 master 2.10.x 3.10.x amd64, arm64
2.9-awshelm3.10 master 2.9.x 3.10.x amd64, arm64
2.8-awshelm3.10 master 2.8.x 3.10.x amd64, arm64
latest-awshelm3.9 master latest 3.9.x amd64, arm64
2.13-awshelm3.9 master 2.13.x 3.9.x amd64, arm64
2.12-awshelm3.9 master 2.12.x 3.9.x amd64, arm64
2.11-awshelm3.9 master 2.11.x 3.9.x amd64, arm64
2.10-awshelm3.9 master 2.10.x 3.9.x amd64, arm64
2.9-awshelm3.9 master 2.9.x 3.9.x amd64, arm64
2.8-awshelm3.9 master 2.8.x 3.9.x amd64, arm64
latest-awshelm3.8 master latest 3.8.x amd64, arm64
2.13-awshelm3.8 master 2.13.x 3.8.x amd64, arm64
2.12-awshelm3.8 master 2.12.x 3.8.x amd64, arm64
2.11-awshelm3.8 master 2.11.x 3.8.x amd64, arm64
2.10-awshelm3.8 master 2.10.x 3.8.x amd64, arm64
2.9-awshelm3.8 master 2.9.x 3.8.x amd64, arm64
2.8-awshelm3.8 master 2.8.x 3.8.x amd64, arm64
latest-awshelm3.7 master latest 3.7.x amd64, arm64
2.13-awshelm3.7 master 2.13.x 3.7.x amd64, arm64
2.12-awshelm3.7 master 2.12.x 3.7.x amd64, arm64
2.11-awshelm3.7 master 2.11.x 3.7.x amd64, arm64
2.10-awshelm3.7 master 2.10.x 3.7.x amd64, arm64
2.9-awshelm3.7 master 2.9.x 3.7.x amd64, arm64
2.8-awshelm3.7 master 2.8.x 3.7.x amd64, arm64
latest-awshelm3.6 master latest 3.6.x amd64, arm64
2.13-awshelm3.6 master 2.13.x 3.6.x amd64, arm64
2.12-awshelm3.6 master 2.12.x 3.6.x amd64, arm64
2.11-awshelm3.6 master 2.11.x 3.6.x amd64, arm64
2.10-awshelm3.6 master 2.10.x 3.6.x amd64, arm64
2.9-awshelm3.6 master 2.9.x 3.6.x amd64, arm64
2.8-awshelm3.6 master 2.8.x 3.6.x amd64, arm64
latest-awshelm3.5 master latest 3.5.x amd64, arm64
2.13-awshelm3.5 master 2.13.x 3.5.x amd64, arm64
2.12-awshelm3.5 master 2.12.x 3.5.x amd64, arm64
2.11-awshelm3.5 master 2.11.x 3.5.x amd64, arm64
2.10-awshelm3.5 master 2.10.x 3.5.x amd64, arm64
2.9-awshelm3.5 master 2.9.x 3.5.x amd64, arm64
2.8-awshelm3.5 master 2.8.x 3.5.x amd64, arm64
latest-awshelm3.4 master latest 3.4.x amd64, arm64
2.13-awshelm3.4 master 2.13.x 3.4.x amd64, arm64
2.12-awshelm3.4 master 2.12.x 3.4.x amd64, arm64
2.11-awshelm3.4 master 2.11.x 3.4.x amd64, arm64
2.10-awshelm3.4 master 2.10.x 3.4.x amd64, arm64
2.9-awshelm3.4 master 2.9.x 3.4.x amd64, arm64
2.8-awshelm3.4 master 2.8.x 3.4.x amd64, arm64
latest-awshelm3.3 master latest 3.3.x amd64, arm64
2.13-awshelm3.3 master 2.13.x 3.3.x amd64, arm64
2.12-awshelm3.3 master 2.12.x 3.3.x amd64, arm64
2.11-awshelm3.3 master 2.11.x 3.3.x amd64, arm64
2.10-awshelm3.3 master 2.10.x 3.3.x amd64, arm64
2.9-awshelm3.3 master 2.9.x 3.3.x amd64, arm64
2.8-awshelm3.3 master 2.8.x 3.3.x amd64, arm64
latest-awshelm3.2 master latest 3.2.x amd64, arm64
2.13-awshelm3.2 master 2.13.x 3.2.x amd64, arm64
2.12-awshelm3.2 master 2.12.x 3.2.x amd64, arm64
2.11-awshelm3.2 master 2.11.x 3.2.x amd64, arm64
2.10-awshelm3.2 master 2.10.x 3.2.x amd64, arm64
2.9-awshelm3.2 master 2.9.x 3.2.x amd64, arm64
2.8-awshelm3.2 master 2.8.x 3.2.x amd64, arm64
latest-awshelm3.1 master latest 3.1.x amd64, arm64
2.13-awshelm3.1 master 2.13.x 3.1.x amd64, arm64
2.12-awshelm3.1 master 2.12.x 3.1.x amd64, arm64
2.11-awshelm3.1 master 2.11.x 3.1.x amd64, arm64
2.10-awshelm3.1 master 2.10.x 3.1.x amd64, arm64
2.9-awshelm3.1 master 2.9.x 3.1.x amd64, arm64
2.8-awshelm3.1 master 2.8.x 3.1.x amd64, arm64
latest-awshelm3.0 master latest 3.0.x amd64, arm64
2.13-awshelm3.0 master 2.13.x 3.0.x amd64, arm64
2.12-awshelm3.0 master 2.12.x 3.0.x amd64, arm64
2.11-awshelm3.0 master 2.11.x 3.0.x amd64, arm64
2.10-awshelm3.0 master 2.10.x 3.0.x amd64, arm64
2.9-awshelm3.0 master 2.9.x 3.0.x amd64, arm64
2.8-awshelm3.0 master 2.8.x 3.0.x amd64, arm64
latest-awshelm2.16 master latest 2.16.x amd64, arm64
2.13-awshelm2.16 master 2.13.x 2.16.x amd64, arm64
2.12-awshelm2.16 master 2.12.x 2.16.x amd64, arm64
2.11-awshelm2.16 master 2.11.x 2.16.x amd64, arm64
2.10-awshelm2.16 master 2.10.x 2.16.x amd64, arm64
2.9-awshelm2.16 master 2.9.x 2.16.x amd64, arm64
2.8-awshelm2.16 master 2.8.x 2.16.x amd64, arm64

🆕 Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker Tag Git Ref Available Architectures
<docker-tag>-<tag> git: <tag> amd64, arm64
  • Where <docker-tag> refers to any of the tags listed in Rolling releases above.
  • Where <tag> refers to the chosen git tag from this repository.

🔠 Docker environment variables

Environment variables are available for all flavours except for Ansible base.

Variable Default Allowed values Description
USER `` ansible Set this to ansible to have everything run inside the container by the user ansible instead of root
UID 1000 integer If your local uid is not 1000 set it to your uid to syncronize file/dir permissions during mounting
GID 1000 integer If your local gid is not 1000 set it to your gid to syncronize file/dir permissions during mounting
INIT_GPG_KEY `` string If your gpg key requires a password you can initialize it during startup and cache the password (requires INIT_GPG_PASS as well)
INIT_GPG_PASS `` string If your gpg key requires a password you can initialize it during startup and cache the password (requires INIT_GPG_KEY as well)
INIT_GPG_CMD `` string A custom command which will initialize the GPG key password. This allows for interactive mode to enter your password manually during startup. (Mutually exclusive to INIT_GPG_KEY and INIT_GPG_PASS)

📂 Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally to the root of your project where your Ansible playbooks are.

ℹ️ Examples

Run Ansible playbook

docker run --rm -v $(pwd):/data cytopia/ansible ansible-playbook playbook.yml

Run Ansible playbook with Mitogen

Mitogen updates Ansible’s slow and wasteful shell-centric implementation with pure-Python equivalents, invoked via highly efficient remote procedure calls to persistent interpreters tunnelled over SSH.

No changes are required to target hosts. The extension is considered stable and real-world use is encouraged.

Configuration (option 1)

ansible.cfg

[defaults]
strategy_plugins = /usr/lib/python3.10/site-packages/ansible_mitogen/plugins/strategy
strategy         = mitogen_linear

Configuratoin (option 2)

# Instead of hardcoding it via ansible.cfg,  you could also add the
# option on-the-fly via environment variables.
export ANSIBLE_STRATEGY_PLUGINS=/usr/lib/python3.10/site-packages/ansible_mitogen/plugins/strategy
export ANSIBLE_STRATEGY=mitogen_linear

Invocation

docker run --rm -v $(pwd):/data cytopia/ansible:latest-tools ansible-playbook playbook.yml

Further readings:

Run Ansible playbook with non-root user

# Use 'ansible' user inside Docker container
docker run --rm \
  -e USER=ansible \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml
# Use 'ansible' user inside Docker container
# Use custom uid/gid for 'ansible' user inside Docker container
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Run Ansible playbook with local ssh keys mounted

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -v ${HOME}/.ssh/:/home/ansible/.ssh/ \
  -v ${SSH_AUTH_SOCK}:/ssh-agent --env SSH_AUTH_SOCK=/ssh-agent \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Run Ansible playbook with local password-less gpg keys mounted

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -v ${HOME}/.gnupg/:/home/ansible/.gnupg/ \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Run Ansible playbook with local gpg keys mounted and automatically initialized

This is required in case your GPG key itself is encrypted with a password. Note that the password needs to be in single quotes.

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -e [email protected] \
  -e INIT_GPG_PASS='my gpg password' \
  -v ${HOME}/.gnupg/:/home/ansible/.gnupg/ \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Alternatively you can also export your GPG key and password to the shell's environment:

# Ensure to write the password in single quotes
export MY_GPG_KEY='[email protected]'
export MY_GPG_PASS='my gpg password'
# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -e INIT_GPG_KEY=${MY_GPG_KEY} \
  -e INIT_GPG_PASS=${MY_GPG_PASS} \
  -v ${HOME}/.gnupg/:/home/ansible/.gnupg/ \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Run Ansible playbook with local gpg keys mounted and interactively interactively

The following will work with password-less and password-set GPG keys. In case it requires a password, it will ask for the password and you need to enter it.

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -e INIT_GPG_CMD='echo test | gpg --encrypt -r [email protected] | gpg --decrypt --pinentry-mode loopback' \
  -v ${HOME}/.gnupg/:/home/ansible/.gnupg/ \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-playbook playbook.yml

Run Ansible Galaxy

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -v $(pwd):/data \
  cytopia/ansible:latest-tools ansible-galaxy install -r requirements.yml

Run Ansible playbook with AWS credentials

# Basic
docker run --rm \
  -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
  -v $(pwd):/data \
  cytopia/ansible:latest-aws ansible-playbook playbook.yml
# With AWS Session Token
docker run --rm \
  -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
  -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
  -v $(pwd):/data \
  cytopia/ansible:latest-aws ansible-playbook playbook.yml
# With ~/.aws/ config and credentials directories mounted (read/only)
# If you want to make explicit use of aws profiles, use this variant
# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -v ${HOME}/.aws/config:/home/ansible/.aws/config:ro \
  -v ${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
  -v $(pwd):/data \
  cytopia/ansible:latest-aws ansible-playbook playbook.yml

Run Ansible playbook against AWS with gpg vault initialization

# Ensure to set same uid/gid as on your local system for Docker user
# to prevent permission issues during docker mounts
docker run --rm \
  -e USER=ansible \
  -e MY_UID=1000 \
  -e MY_GID=1000 \
  -e [email protected] \
  -e INIT_GPG_PASS='my gpg password' \
  -v ${HOME}/.aws/config:/home/ansible/.aws/config:ro \
  -v ${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
  -v ${HOME}/.gnupg/:/home/ansible/.gnupg/ \
  -v $(pwd):/data \
  cytopia/ansible:latest-aws \
  ansible-playbook playbook.yml

As the command is getting pretty long, you could wrap it into a Makefile.

ifneq (,)
.error This Makefile requires GNU Make.
endif

.PHONY: dry run

CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
ANSIBLE = 2.8
UID = 1000
GID = 1000

# Ansible check mode uses mitogen_linear strategy for much faster roll-outs
dry:
ifndef GPG_PASS
	docker run --rm -it \
		-e ANSIBLE_STRATEGY_PLUGINS=/usr/lib/python3.10/site-packages/ansible_mitogen/plugins/strategy \
		-e ANSIBLE_STRATEGY=mitogen_linear \
		-e USER=ansible \
		-e MY_UID=$(UID) \
		-e MY_GID=$(GID) \
		-v $${HOME}/.aws/config:/home/ansible/.aws/config:ro \
		-v $${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
		-v $${HOME}/.gnupg/:/home/ansible/.gnupg/ \
		-v $(CURRENT_DIR):/data \
		cytopia/ansible:$(ANSIBLE)-aws \
		ansible-playbook playbook.yml --check
else
	docker run --rm -it \
		-e ANSIBLE_STRATEGY_PLUGINS=/usr/lib/python3.10/site-packages/ansible_mitogen/plugins/strategy \
		-e ANSIBLE_STRATEGY=mitogen_linear \
		-e USER=ansible \
		-e MY_UID=$(UID) \
		-e MY_GID=$(GID) \
		-e INIT_GPG_KEY=$${GPG_KEY} \
		-e INIT_GPG_PASS=$${GPG_PASS} \
		-v $${HOME}/.aws/config:/home/ansible/.aws/config:ro \
		-v $${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
		-v $${HOME}/.gnupg/:/home/ansible/.gnupg/ \
		-v $(CURRENT_DIR):/data \
		cytopia/ansible:$(ANSIBLE)-aws \
		ansible-playbook playbook.yml --check
endif

# Ansible real run uses default strategy
run:
ifndef GPG_PASS
	docker run --rm -it \
		-e USER=ansible \
		-e MY_UID=$(UID) \
		-e MY_GID=$(GID) \
		-v $${HOME}/.aws/config:/home/ansible/.aws/config:ro \
		-v $${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
		-v $${HOME}/.gnupg/:/home/ansible/.gnupg/ \
		-v $(CURRENT_DIR):/data \
		cytopia/ansible:$(ANSIBLE)-aws ansible-playbook playbook.yml
else
	docker run --rm -it \
		-e USER=ansible \
		-e MY_UID=$(UID) \
		-e MY_GID=$(GID) \
		-e INIT_GPG_KEY=$${GPG_KEY} \
		-e INIT_GPG_PASS=$${GPG_PASS} \
		-v $${HOME}/.aws/config:/home/ansible/.aws/config:ro \
		-v $${HOME}/.aws/credentials:/home/ansible/.aws/credentials:ro \
		-v $${HOME}/.gnupg/:/home/ansible/.gnupg/ \
		-v $(CURRENT_DIR):/data \
		cytopia/ansible:$(ANSIBLE)-aws \
		ansible-playbook playbook.yml
endif

Important:

THE GPG_KEY and GPG_PASS will not be echo'ed out by the Make command and you are advised to export those values via your shell's export command to the env in order to hide it.

If you still want to specify them on the command line via make dry GPG_KEY='pass' and your pass or key contains one or more $ characters then they must all be escaped with an additional $ in front. This is not necessary if you export them.

Example: If your password is test$5, then you must use make dry GPG_PASS='test$$5'.

Then you can call it easily:

# With GPG password from the env
export GPG_KEY='[email protected]'
export GPG_PASS='THE_GPG_PASSWORD_HERE'
make dry
make run

# With GPG password on the cli
make dry GPG_KEY='[email protected]' GPG_PASS='THE_GPG_PASSWORD_HERE'
make run GPG_KEY='[email protected]' GPG_PASS='THE_GPG_PASSWORD_HERE'

# Without GPG password
make dry
make run

# With different Ansible version
make dry ANSIBLE=2.6
make run ANSIBLE=2.6

# With different uid/gid
make dry UID=1001 GID=1001
make run UID=1001 GID=1001

💻 Build locally

To build locally you require GNU Make to be installed. Instructions as shown below.

amd64 vs arm64

If you want to build the Ansible image for a different platform, use the ARCH make variable as shown below. This also applies to all other examples below.

# Build amd64 images (default)
make build
make build ARCH=linux/amd64

# Build arm64 images
make build ARCH=linux/arm64

Ansible base

# Build latest Ansible base
# image: cytopia/ansible:latest
make build

# Build Ansible 2.6 base
# image: cytopia/ansible:2.6
make build VERSION=2.6

Ansible tools

# Build latest Ansible tools
# image: cytopia/ansible:latest-tools
make build VERSION=latest STAGE=tools

# Build Ansible 2.6 tools
# image: cytopia/ansible:2.6-tools
make build VERSION=2.6 STAGE=tools

Ansible infra

# Build latest Ansible infra
# image: cytopia/ansible:latest-infra
make build VERSION=latest STAGE=infra

# Build Ansible 2.6 infra
# image: cytopia/ansible:2.6-infra
make build VERSION=2.6 STAGE=infra

Ansible azure

# Build latest Ansible azure
# image: cytopia/ansible:latest-azure
make build VERSION=latest STAGE=azure

# Build Ansible 2.6 azure
# image: cytopia/ansible:2.6-azure
make build VERSION=2.6 STAGE=azure

Ansible aws

# Build latest Ansible aws
# image: cytopia/ansible:latest-aws
make build VERSION=latest STAGE=aws

# Build Ansible 2.6 aws
# image: cytopia/ansible:2.6-aws
make build VERSION=2.6 STAGE=aws

Ansible awsk8s

# Build latest Ansible awsk8s
# image: cytopia/ansible:latest-awsk8s
make build VERSION=latest STAGE=awsk8s

# Build Ansible 2.6 awsk8s
# image: cytopia/ansible:2.6-awsk8s
make build VERSION=2.6 STAGE=awsk8s

Ansible awskops

# Build latest Ansible with Kops 1.8
# image: cytopia/ansible:latest-awskops1.8
make build VERSION=latest STAGE=awskops KOPS=1.8

# Build Ansible 2.6 with Kops 1.8
# image: cytopia/ansible:2.6-awskops1.8
make build VERSION=2.6 STAGE=awskops KOPS=1.8

Ansible awshelm

# Build latest Ansible with Helm 2.14
# image: cytopia/ansible:latest-awshelm2.14
make build VERSION=latest STAGE=awshelm HELM=2.14

🔄 Related #awesome-ci projects

Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHub DockerHub Type Description
awesome-ci aci-hub-img Basic Tools for git, file and static source code analysis
file-lint flint-hub-img Basic Baisc source code analysis
linkcheck linkcheck-hub-img Basic Search for URLs in files and validate their HTTP status code
ansible ansible-hub-img Ansible Multiple versions and flavours of Ansible
ansible-lint alint-hub-img Ansible Lint Ansible
gofmt gfmt-hub-img Go Format Go source code [1]
goimports gimp-hub-img Go Format Go source code [1]
golint glint-hub-img Go Lint Go code
eslint elint-hub-img Javascript Lint Javascript code
jsonlint jlint-hub-img JSON Lint JSON files [1]
kubeval kubeval-hub-img K8s Lint Kubernetes files
checkmake cm-hub-img Make Lint Makefiles
phpcbf pcbf-hub-img PHP PHP Code Beautifier and Fixer
phpcs pcs-hub-img PHP PHP Code Sniffer
phplint plint-hub-img PHP PHP Code Linter [1]
php-cs-fixer pcsf-hub-img PHP PHP Coding Standards Fixer
bandit bandit-hub-img Python A security linter from PyCQA
black black-hub-img Python The uncompromising Python code formatter
mypy mypy-hub-img Python Static source code analysis
pycodestyle pycs-hub-img Python Python style guide checker
pydocstyle pyds-hub-img Python Python docstyle checker
pylint pylint-hub-img Python Python source code, bug and quality checker
terraform-docs tfdocs-hub-img Terraform Terraform doc generator (TF 0.12 ready) [1]
terragrunt tg-hub-img Terraform Terragrunt and Terraform
terragrunt-fmt tgfmt-hub-img Terraform terraform fmt for Terragrunt files [1]
yamlfmt yfmt-hub-img Yaml Format Yaml files [1]
yamllint ylint-hub-img Yaml Lint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

📄 License

MIT License

Copyright (c) 2019 cytopia

More Repositories

1

devilbox

A modern Docker LAMP stack and MEAN stack for local development
PHP
4,153
star
2

ffscreencast

ffscreencast - ffmpeg screencast/desktop-recording with video overlay and multi monitor support
Shell
1,742
star
3

pwncat

pwncat - netcat on steroids with Firewall, IDS/IPS evasion, bind and reverse shell, self-injecting shell and port forwarding magic - and its fully scriptable with Python (PSE)
Shell
1,624
star
4

linux-timemachine

Rsync-based OSX-like time machine for Linux, MacOS and BSD for atomic and resumable local and remote backups
Shell
674
star
5

awesome-ci

Awesome Continuous Integration - Lot's of tools for git, file and static source code analysis.
Shell
322
star
6

badchars

Bad char generator to instruct encoders such as shikata-ga-nai to transform those to other chars.
Python
221
star
7

urlbuster

Powerful mutable web directory fuzzer to bruteforce existing and/or hidden files or directories.
Python
152
star
8

mysqldump-secure

[sh] Encrypted mysqldump script with compression, logging, blacklisting and Nagios/Icinga monitoring integration
Shell
141
star
9

thunar-custom-actions

Custom actions for Thunar (or Nautilus) File manager
Shell
135
star
10

ansible-debian

Buildfiles: Ansible automated leight-weight and sensible Debian provisioning
Jinja
86
star
11

smtp-user-enum

SMTP user enumeration via VRFY, EXPN and RCPT with clever timeout, retry and reconnect functionality.
Python
83
star
12

coinwatch

Coinmarketcap console client to keep track of your crypto currency trades - are you winning or losing?
Python
78
star
13

docker-bind

Bind (bind9) caching DNS server on Alpine or Debian with wild-card domain support [multi-arch]
Shell
77
star
14

docker-terraform-docs

Alpine-based multistage-build version of terraform-docs and terraform-docs-replace in multiple versions to be used for CI and other reproducible automations
HCL
60
star
15

crawlpy

Scrapy python crawler/spider with post/get login (handles CSRF), variable level of recursions and optionally save to disk
Python
55
star
16

aws-export-profile

Export AWS profiles to your shell environment
Shell
46
star
17

docker-dvwa

Docker Compose setup for DVWA with all available PHP versions
Makefile
44
star
18

ansible-role-cloudformation

Ansible role to render an arbitrary number of Jinja2 templates into cloudformation files and create any number of stacks.
Python
43
star
19

aws-export-assume-profile

Export AWS profiles to your shell environment
Shell
41
star
20

i3blocks-modules

Custom modules for i3blocks status bar
Shell
40
star
21

docker-terragrunt

Alpine-based multistage-build version of Terragrunt and Terraform for reproducible usage in CI
Makefile
40
star
22

fuzza

Customizable TCP fuzzing tool to test for remote buffer overflows.
Python
32
star
23

docker-yamllint

Alpine-based multistage-build of yamllint for reproducible usage in CI
Makefile
30
star
24

autorunner

Configurable and notification aware autostart helper for minimalistic window managers like i3, openbox and others
Shell
29
star
25

check_drupal

[sh] Nagios drupal plugin to monitor the state of a drupal site (or multisite) for security updates, core errors and more
Shell
27
star
26

ansible-role-k8s

This role render an arbitrary number of Jinja2 templates and deploys or removes them to/from Kubernetes clusters.
Python
26
star
27

redmine-like-a-boss

[sh] Simple redmine installation with plugins and themes
Shell
25
star
28

makefiles

Makefile
25
star
29

linkcheck

Search for URLs in files (optionally limited by extension) and validate their HTTP status code
Shell
23
star
30

aws-ec2-sg-exporter

A dockerized Prometheus exporter that compares desired/wanted IPv4/IPv6 CIDR against currently applied inbound CIDR rules in your security group(s).
Shell
22
star
31

kusanagi

Kusanagi is a bind and reverse shell payload generator with obfuscation and badchar support.
Python
21
star
32

metrics-server-prom

Prometheus adapter to scrape from Kubernetes metrics-server
Python
21
star
33

docker-black

Alpine-based multistage-build version of Python Black for reproducible usage in CI
Roff
20
star
34

ansible-modules

Custom ansible modules
Python
18
star
35

terraform-aws-iam

This Terraform module manages AWS IAM to its full extend.
HCL
18
star
36

dotfiles

dotfiles
Shell
17
star
37

docker-phpcs

Alpine-based multistage-build version of phpcs for reproducible usage in CI
Makefile
16
star
38

kali-openbox-menu

Kali-Linux menu for openbox
16
star
39

docker-php-cs-fixer

Alpine-based multistage-build version of php-cs-fixer for reproducible usage in CI
Makefile
16
star
40

git-rewrite-author

[sh] Rewrite git author and committer history (locally and remotely)
Shell
16
star
41

docker-ansible-lint

Alpine-based multistage-build version of ansible-lint for reproducible usage in CI
Makefile
14
star
42

nginx-certwatch

[sh] certwatch cron implementation for nginx vhosts
Shell
13
star
43

awesome-nagios-plugins

A curated list of awesome nagios plugins
13
star
44

docker-file-lint

Alpine-based Docker image to perform generic file checks on your source code in order to improve consistency within your repository (e.g. for easy usage in CI).
Shell
12
star
45

terraform-aws-route53-zone

A Terraform module that handles creation of multiple Route53 zones including attachment to new or existing delegation set
HCL
12
star
46

ansible-module-diff

Ansible module to diff strings, file contents or command outputs against each other
Python
11
star
47

slidocli

Command line utility to list available questions on sli.do and automatically upvote any question specified by their id.
Shell
11
star
48

yolo

discover new commands
Shell
10
star
49

docker-gofmt

Alpine-based multistage-build version of gofmt for reproducible usage in CI
Shell
9
star
50

header-fuzz

header-fuzz allows you to fuzz any HTTP header with a wordlist and evaluate success or failure based on the returning HTTP status code.
Shell
9
star
51

ultimate-shell-template

The ultimate shell template with optional GUI support
Shell
9
star
52

check_php

[sh] Nagios plugin for PHP to check for startup errors, missing modules, wrong php.ini configurations and PHP updates.
Shell
9
star
53

check_git

Nagios plugin to monitor the state of a git repository: clean, branch, tag, gpg verified etc
Shell
9
star
54

ansible-role-aws_account_match

Ansible safe-guard role to ensure you are currently using the correct AWS account(s)
9
star
55

docker-pylint

Alpine-based multistage-build version of pylint for reproducible usage in CI
Makefile
9
star
56

letsencrypt-watch

[sh] certwatch cron implementation for letsencrypt certificates
Shell
9
star
57

lsl

Colorful file labels for you terminal which are displayed in ls output.
Shell
8
star
58

docker-eslint

Alpine-based multistage-build version of eslint for reproducible usage in CI
Makefile
8
star
59

docker-yamlfmt

Alpine-based multistage-build version of yamlfmt for reproducible usage in CI
Makefile
8
star
60

docker-golint

Alpine-based multistage-build version of golint for reproducible usage in CI
Makefile
8
star
61

i3-utils-bin

Shell
7
star
62

docker-phplint

Alpine-based version of PHP for linting and reproducible usage in CI
Makefile
7
star
63

docker-linkcheck

Alpine-based multistage-build version of linkcheck for reproducible usage in CI
Makefile
7
star
64

docker-mypy

Alpine-based multistage-build version of Python mypy for reproducible usage in CI
Roff
6
star
65

terraform-aws-iam-cross-account

This Terraform module creates AWS cross-account assumable roles with multiple polcies to be specified via files
HCL
6
star
66

ansible-filter-get_attr

Ansible filter to have variable substitution in keys and values inside dictionaries
Python
6
star
67

docker-bandit

Alpine-based multistage-build version of bandit for reproducible usage in CI
Makefile
6
star
68

docker-terragrunt-fmt

Alpine-based multistage-build version of terragrunt-fmt to be used for CI and other reproducible automations
Shell
6
star
69

docker-jsonlint

Alpine-based multistage-build version of jsonlint with file globbing search for reproducible usage in CI
Makefile
6
star
70

docker-phpcbf

Alpine-based multistage-build version of phpcbf for reproducible usage in CI
Makefile
6
star
71

yii-check-translations

Shell script to check/validate yii translations in various folders
PHP
5
star
72

docker-goimports

Alpine-based multistage-build version of goimports for reproducible usage in CI
Shell
5
star
73

check_http_expect

[sh] Nagios plugin that will check a website (behind .htacess and/or behind POST login) for an expected string or regex expression.
Shell
5
star
74

vault-auto-unseal

HashiCorp Vault auto-unseal
Shell
5
star
75

jsparsy

Scan urls for javascript run-time errors
JavaScript
5
star
76

docker-checkmake

Alpine-based multistage-build version of checkmake for reproducible usage in CI
Makefile
5
star
77

dotfiles-kali

Shell
4
star
78

git-ids

Use git as an intrusion detection system for your servers
4
star
79

sweany

Sweany is a performance-orientated, self-validating and feature-rich MVC framework for PHP
PHP
4
star
80

terraform-aws-elb

This Terraform module creates an ELB with optionally a public and/or private Route53 DNS record attached to it.
HCL
4
star
81

docker-pycodestyle

Alpine-based multistage-build version of pycodestyle for reproducible usage in CI
Makefile
4
star
82

upload-artifact-verify-action

4
star
83

upload-artifact-retry-action

This action allows you to upload an artifact with retries in case the upload has failed. It wraps upload-artifact-verify-action and retries it
4
star
84

freebsd-tools

[sh] FreeBSD script collection
Shell
3
star
85

i3-utils

Some tools I use for my i3 setup
3
star
86

ecss

Exteended CSS (ECSS) is a preprocessor that easily adds constants and inheritance (single, multiple & recursive) as a language construct
PHP
3
star
87

docker-tag-action

GitHub Action to create Docker tag based on git branch or git tag
3
star
88

prometheus-redbox_exporter

Prometheus exporter that throws stuff to httpd endpoints and evaluates their response
Python
3
star
89

terraform-aws-rds

Remake of terraform-aws-modules/terraform-aws-rds without sub-modules
HCL
3
star
90

docker-pydocstyle

Alpine-based multistage-build version of pydocstyle for reproducible usage in CI
Makefile
2
star
91

asm

Assembly
2
star
92

git-tools

Shell
2
star
93

tools

Various cli tools
Shell
2
star
94

check_mysqldump-secure

[sh] Nagios Plugin to monitor mysqldump database backups
Shell
2
star
95

i3-utils-systemd

Makefile
2
star
96

docker-kubeval

Alpine-based multistage-build version of kubeval for reproducible usage in CI
Makefile
2
star
97

homebrew-tap

[ruby] Cytopia's homebrews
Ruby
2
star
98

download-artifact-retry-action

2
star
99

git-ref-matrix-action

This composite action creates a stringified JSON list of git refs to be used as a build matrix.
2
star
100

terraform-aws-iam-roles

This Terraform module creates an arbitrary number of IAM roles and policies/trusts to attach.
HCL
2
star