Ansible runner container for provision docker host from inside container
1.9K
This container allows you to provision a machine running docker via ansible running inside a container. This works by creating a temporary SSH key inside the container, adding it to the authorized_keys on the host and then performing a remote ansible play against localhost.
Quick One-liner:
docker run -it --rm --net host -v [host ssh key dir]:/hostssh -v [host playbook dir]:[mounted playbook dir] pp2l/ansible-runner [ansible args]
Quick Example:
docker run -it --rm --net host -v ~/.ssh:/hostssh -v /my/playbooks/:/provisioning pp2l/ansible-runner /playbooks/provision.yaml
To run this, there are a few things you must pass to this container...
The SSH config directory of the user Ansible will connect via. This is needed to enable Ansible to connect back to the host machine by inserting a key into the authorized_keys file. This directory must be mounted at /hostssh inside the container. By default, Ansible will connect to the host machine as root. You can override this by specifying an ANSIBLE_USER environment variable.
The Anisble playbook directory. You can pass this in two ways:
/provisioningGIT_URL and GIT_COMMIT environment variables respectively.The docker parameter --net host. This ensures that localhost inside the container is the actually host machine.
Some ansible arguments.. Pass the standard ansible-playbook arguments you would normally use to run your playbook at the end of the docker run command.
TODO: Put some more realistic examples here!
docker run docker run -it --rm --net host -v ~/.ssh:/hostssh -v /my/playbooks/:/provisioning pp2l/ansible-runner /provisioning/provision.yaml
docker run docker run -it --rm --net host -v ~/.ssh:/hostssh -e GIT_URL="[email protected]/repos/remote.git" -e GIT_COMMIT="my_branch" pp2l/ansible-runner /provisioning/provision.yaml
** NOTE: This will assume that the remote repo is public, keys are a WIP!
Content type
Image
Digest
Size
144.5 MB
Last updated
about 10 years ago
docker pull pp2l/ansible-runner