2.1, 2, latest (Dockerfile)Ansible is a free-software platform for configuring and managing computers which combines multi-node software deployment, ad hoc task execution, and configuration management.
Alpine Linux image with the following applications installed:
This image can be used for:
You can test your playbooks just mounting your playbook directory into the container.
$ docker run -it --rm -v /my-playbooks:/playbooks jfusterm/ansible sh
/ # ansible-playbook /playbooks/main.yml
Instead of using Dockerfiles to build images, you can provision Docker images using Packer with Ansible. Having for instance a JSON file called docker.json and a playbook called nginx.yml, you can build a Docker image with Nginx on it.
{
"builders": [
{
"type": "docker",
"image": "jfusterm/ansible",
"commit": true
}
],
"provisioners": [
{
"type": "ansible-local",
"playbook_dir": "/my-playbooks",
"playbook_file": "nginx.yml"
}
],
"post-processors": [
{
"type": "docker-tag",
"repository": "my-image",
"tag": "1.0"
}
]
}
---
- name: Nginx installation
apk:
name=nginx
state=present
update_cache=yes
Now we can just build our Docker image.
$ packer build docker.json
...
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image 1.0 929fd63420c1 7 seconds ago 71.07 MB
Content type
Image
Digest
Size
21.9 MB
Last updated
over 10 years ago
docker pull jfusterm/ansible