arnaudblancher.docker_provisionning

arnaudblancher.docker_provisioning

Goal

The goal of this project is to take an Ansible inventory and create one Docker container for each host listed.

After that, you can deploy your favorite Ansible playbook on these Docker containers and easily conduct full tests in a new, clean environment without the need for new virtual machines.

Once you're done testing, you can simply remove these Docker containers using the Ansible role arnaudblancher.docker_unprovisioning.

Requirements

  • Docker Engine

Make sure Docker Engine is running. You can test if it's working with the following command (you may need to run it as root):

docker info

If you need to install Docker Engine

To install Docker Engine version 1.11 on Debian Jessie, use the following commands:

apt-get remove docker.io python-docker
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo debian-jessie main' > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install docker-engine python-docker

For Ubuntu Trusty, replace python-docker with:

sudo apt-get install python-pip
sudo pip install docker-py

Role Variables

Please see defaults/main.yml for configurable variables.

Dependencies

None.

Example Playbook

Refer to the subdirectory ./demo/ for examples.

Example Playbook File: demo/docker-provisioning.yml

- name: "Create all Docker images and containers for all hosts listed in inventory"
  hosts: localhost
  gather_facts: no

  roles:
    - { role: arnaudblancher.docker_provisionning,
      docker_provisionning_net: "ansible_myplatform" }

Inventory File: inventory/docker/000_hosts

[mysql]
# Use the default docker_provisionning_image configured in defaults/main.yml
dock_mysql

[apache]
# Specify a specific docker_provisionning_image for this container
dock_apache docker_provisionning_image="ubuntu1604"

[jmeter]
# Optional: specify an alternate Dockerfile path outside the role;
# the path must be relative to roles/arnaudblancher.docker_provisionning/dockerfiles/
dock_jmeter docker_provisionning_image="jmeter2.13private"  docker_provisionning_dockerfile="../../../local_files/dockerfiles/jmeter2.13private"

[all:vars]
ansible_connection=docker

Group Variables: group_vars/all

# Override the default/main.yml OS for docker_provisionning
docker_provisionning_image: "ubuntu1404"

Group Variables for Docker: inventory/docker/group_vars/all

# Add host aliases for containers
docker_provisionning_aliases:
  dock_mysql:
    - "bdd01"
    - "bdd02"
  dock_apache:
    - www01
    - www02
    - www03

Running the Playbook

Execute the following command to run the playbook:

ansible-playbook -i inventory/docker/ docker-provisionning.yml

License

GPLv3

Author Information

Arnaud Blancher

GitHub Repository

Informazioni sul progetto

Take an ansible inventory and create one docker container for each listed hosts. After you can deploy your favorite ansible playbook on theses docker-inventory and make easily and safely full tests in a new and clean environnement.

Installa
ansible-galaxy install arnaudblancher.docker_provisionning
Licenza
Unknown
Download
111
Proprietario