Skip to content

Latest commit

 

History

History
67 lines (42 loc) · 2.39 KB

README.md

File metadata and controls

67 lines (42 loc) · 2.39 KB

Ansible Docker container

Ansible client container aimed to behave as much as possible as a locally installed Ansible.

Allows to run Ansible with a configuration on your local host using ssh keys and config from your localhost, updating any host in your network. This makes it very easy to get started with Ansible.

Setup

Install

The easiest way to use this image is to install the wrapper scripts in a folder in your path. For example:

docker pull bertbaron/ansible
docker run --rm -ti -v /usr/local/bin:/workdir bertbaron/ansible setup

This will create wrapper scripts for the ansible commands in /usr/local/bin.1

The scripts run ansible as usual, mounting the current working directory to /workdir and the ~/.ssh directory to /home/user/.ssh.

1 You can use any other folder (i.e. $HOME/bin), just make sure the folder is in your path

Updating / switching between ansible versions

Instead of running the setup command again the version can also be easily updated using:

ansible-update

Uninstall

To uninstall, run:

ansible-uninstall

Usage

The scripts can be used as is, but note that you need to specify the hosts file explicitly because the command only sees the current working directory. Personally I use a simple wrapper script like the following:

#!/bin/bash
ansible-playbook -i hosts -b --vault-password-file=/home/user/.ssh/.pwd site.yml "$@"

About this image

Reasons to use Ansible from a container:

  • No other local requirements than docker
  • Ansible version independent from the one that may be provided by the OS package management

Reason to make yet another Ansible container:

  • In contrary to other containers I tried this container allows to use the authorized ssh keys on the host

Reasons not to use this image: