This repository provides a minimal setup to run Ansible playbooks from inside a Docker container.
Contents
Dockerfile: builds an image based onubuntu:latestwithansible,openssh-client, andsshpassinstalled. The container copiesplaybook.ymlandinventoryand runsansible-playbookby default using--ask-pass.playbook.yml: a simple playbook that:- checks whether a reboot is required and performs it if necessary,
- runs
apt autoremoveto remove no-longer-needed packages.
inventory: a hosts list (expected next toplaybook.ymlinside the container).
Usage
- Build the Docker image:
docker build -t docker-ansible .- Run the container (you will be prompted for the SSH password):
docker run --rm -it \
-v "$PWD/playbook.yml:/ansible/playbook.yml:ro" \
-v "$PWD/inventory:/ansible/inventory:ro" \
docker-ansible