A lightweight docker image to run Terraform and Ansible
5.3K
Terraform AnsibleA 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,Terraform version),SBOM) attestation added using Syft,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:
TerraformExample 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
AnsibleExample 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
MitogenThis image includes mitogen to speed up Ansible playbooks.
ansible.cfgTo 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
docker runIf 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
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
Docker latest tag is 1.16.3-002, 1.16, 1 and has:
| Name | Version | Type |
|---|---|---|
| ansible-core | 2.21.4 | python |
| ansible-lint | 26.8.0 | python |
| ca-certificates | 20260909-r0 | apk |
| curl | 8.22.0-r0 | apk |
| go-task | 3.51.1-r1 | apk |
| hvac | 2.4.0 | python |
| jc | 1.26.0 | python |
| jmespath | 1.1.0 | python |
| jq | 1.8.2-r0 | apk |
| mitogen | 0.3.53 | python |
| netaddr | 1.3.0 | python |
| openssh-client-common | 10.3_p1-r1 | apk |
| openssl | 3.5.8-r0 | apk |
| py3-pip | 26.1.2-r0 | apk |
| pytest-testinfra | 10.2.2 | python |
| python3 | 3.14.7-r1 | apk |
| sshpass | 1.10-r0 | apk |
| yamllint | 1.38.0 | python |
Dockerhub Overview page has the details of the last published image.
Docker tag definition:
Terraform version used,<terraform_version>-<increment>
Example: 1.15.7-001
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'
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.
Content type
Image
Digest
sha256:624fa2c34…
Size
203.2 MB
Last updated
3 days ago
docker pull jfxs/terraform-ansible