Sign inSign up

jfxs/terraform-ansible

By jfxs

•Updated 3 days ago

A lightweight docker image to run Terraform and Ansible

Image
0

5.3K

jfxs/terraform-ansible repository overview

⁠Docker alpine Terraform Ansible

Software License Pipeline Status

A fully automated, multi‑architecture (amd64/arm64) Docker image that bundles Terraform⁠ and Ansible⁠, with continuous builds, regression testing, and CI‑ready tooling for reproducible infrastructure workflows.

  • mitogen⁠ to 1.25x - 7x speedup playbook execution,
  • multiarch with support of amd64 and arm64,
  • automatically kept up to date by Renovate⁠ (base image and Terraform version),
  • image signed with Cosign⁠,
  • a software bill of materials (SBOM) attestation added using Syft⁠,
  • available on Docker Hub and Quay.io.

GitLab The main repository.

Docker Hub The Docker Hub registry.

Quay.io The Quay.io registry.

Since Ansible version 2.10, the Docker image has only ansible-base without any collection. It could be necessary to install them. This image includes:

⁠Running Terraform

Example to run Terraform commands on your current directory:

docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible terraform init
docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible terraform plan
docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible terraform apply

To check the Terraform version bundled in the image:

docker run -t --rm jfxs/terraform-ansible terraform version

⁠Running Ansible

Example to run Ansible playbooks in your current directory:

docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible ansible-playbook playbook.yml

To install collections:

docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible /bin/sh -c "ansible-galaxy collection install ansible.utils && ansible-playbook playbook.yml"

To test playbooks in your current directory with ansible-lint:

docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible ansible-lint playbook.yml

⁠Using Mitogen

This image includes mitogen⁠ to speed up Ansible playbooks.

⁠Configuration via ansible.cfg

To enable Mitogen by default, configure it in your ansible.cfg file:

[defaults]
strategy_plugins = /usr/local/lib/python3/site-packages/ansible_mitogen/plugins/strategy
strategy         = mitogen_linear
⁠Configuration via Environment Variables in docker run

If you do not want to configure a custom ansible.cfg file, you can pass environment variables in docker run:

docker run -it --rm \
  -v $(pwd):/ansible \
  -e ANSIBLE_STRATEGY_PLUGINS="/usr/local/lib/python3/site-packages/ansible_mitogen/plugins/strategy" \
  -e ANSIBLE_STRATEGY="mitogen_linear" \
  jfxs/terraform-ansible ansible-playbook playbook.yml
⁠Configuration via Environment Variables in container shell

You can also set environment variables in the container shell before running ansible-playbook:

docker run -it --rm -v $(pwd):/ansible jfxs/terraform-ansible /bin/sh
export ANSIBLE_STRATEGY_PLUGINS="/usr/local/lib/python3/site-packages/ansible_mitogen/plugins/strategy"
export ANSIBLE_STRATEGY="mitogen_linear"
ansible-playbook playbook.yml

⁠Built with

Docker latest tag is 1.16.3-002, 1.16, 1⁠ and has:

NameVersionType
ansible-core2.21.4python
ansible-lint26.8.0python
ca-certificates20260909-r0apk
curl8.22.0-r0apk
go-task3.51.1-r1apk
hvac2.4.0python
jc1.26.0python
jmespath1.1.0python
jq1.8.2-r0apk
mitogen0.3.53python
netaddr1.3.0python
openssh-client-common10.3_p1-r1apk
openssl3.5.8-r0apk
py3-pip26.1.2-r0apk
pytest-testinfra10.2.2python
python33.14.7-r1apk
sshpass1.10-r0apk
yamllint1.38.0python

Dockerhub Overview page⁠ has the details of the last published image.

⁠Versioning

Docker tag definition:

  • the Terraform version used,
  • a dash
  • an increment to differentiate build with the same version starting at 001
<terraform_version>-<increment>

Example: 1.15.7-001

⁠Signature and attestation

Cosign⁠ public key:

-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEa3yV6+yd/l4zh/tfT6Tx+zn0dhy3
BhFqSad1norLeKSCN2MILv4fZ9GA6ODOlJOw+7vzUvzZVr9IXnxEdjoWJw==
-----END PUBLIC KEY-----

The public key is also available online: https://gitlab.com/op_so/docker/cosign-public-key/-/raw/main/cosign.pub⁠.

To verify an image:

cosign verify --key cosign.pub $IMAGE_URI

To verify and get the SBOM attestation:

cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'

⁠Authors

⁠License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE⁠ for details.

Tag summary

Content type

Image

Digest

sha256:624fa2c34…

Size

203.2 MB

Last updated

3 days ago

docker pull jfxs/terraform-ansible