Skip to content

Docker image containing an up-to-date version of Ansible

Notifications You must be signed in to change notification settings

devture/docker-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

Ansible Docker container image

The goal of this project is to provide an up-to-date version of Ansible that people can run in a (Docker) container.

This project was created for spantaleev/matrix-docker-ansible-deploy (see Using Ansible via Docker).

Building

If you need to build it yourself, instead of using the devture/ansible image that we publish to Docker Hub.

docker build -t devture/ansible:latest -f Dockerfile .

Usage

Usage against a remote SSH host

If you can connect to the remote server using SSH, use the following command:

cd /some/ansible-project

docker run -it --rm \
-w /work \
-v `pwd`:/work \
-v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa:ro \
--entrypoint=/bin/sh \
devture/ansible:latest

You can execute ansible-playbook commands as per normal now.

Usage against the same host

If you'd like to run Ansible in a container on the server, and then target that same server from inside the container, use this:

cd /some/ansible-project

docker run -it --rm \
--privileged \
--pid=host \
-w /work \
-v `pwd`:/work \
--entrypoint=/bin/sh \
devture/ansible:latest

When invoking the ansible-playbook commands, ensure that:

  • you either add --connection=community.docker.nsenter to the command (e.g. ansible-playbook --connection=community.docker.nsenter ...)

  • or that you've set ansible_connection=community.docker.nsenter for each host that needs it in your Ansible hosts file

About

Docker image containing an up-to-date version of Ansible

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published