chrismeyersfsu.provision_docker

provision_docker

This is an Ansible role that helps you test your other roles by automatically creating Docker containers for each of your inventory hosts. You can use your production inventory file to set up these Docker containers for development and testing.

Image

Resource Description
Blog post Example uses of provision_docker
.travis.yml Example TravisCI setup
Dockerfiles Pre-made Docker images that include an init system (to allow using the service module) and an SSH daemon.
chrismeyers/centos6
chrismeyers/centos7
chrismeyers/ubuntu12.04
ubuntu-upstart:14.04
test/playbook_*.yml
role-install_mongod
role-ansible_deps
role-iptables
Sample provision_docker projects and their usage.

NEW docker_connection

This works with Docker for Mac, VirtualBox, VMware Fusion, and native Docker. Using docker_connection does not require any special routing setup.

# inventory
[robots]
optimus image="chrismeyers/ubuntu12.04"
bumblebee image="ubuntu-upstart:14.04"
# test.yml
- name: Start Docker containers for the inventory interface
  hosts: localhost
  roles:
    - role: provision_docker
      provision_docker_privileged: true,
      provision_docker_inventory_group: "{{ groups['robots'] }}"
      provision_docker_use_docker_connection: true

- hosts: robots
  tasks:
    - name: "Greet my new containers"
      ping:
Parameter Required Default Choices Comments
provision_docker_image No chrismeyers/centos6 chrismeyers/centos6, chrismeyers/centos7, chrismeyers/ubuntu12.04, ubuntu-upstart:14.04, others The Docker image to use when starting the container. The listed Docker images support an init system and SSH, allowing you to start/stop services with the service module and SSH access.
provision_docker_privileged No true true/false Run the Docker container in privileged mode.
provision_docker_inventory_group No Names of the hosts in the inventory to bring up Docker containers for. Make sure the Docker image corresponds to the hostname.
provision_docker_inventory No List of <name, image> pairs to bring up Docker containers.
provision_docker_use_docker_connection No false true/false Use the docker_connection plugin to connect to Docker containers instead of default SSH.
provision_docker_network No Any name from available networks, use $ docker network ls to check. Specify which network the Docker container should connect to.
provision_docker_volumes No List of volumes to mount in the container. Use Docker command-line style: /host:/container[:mode].
provision_docker_volumes_from No List of container names to get volumes from.

Mac OS X + docker-machine + VMware Fusion

Run the following command to set up routing:

sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip default)

Mac OS X + docker-machine + VirtualBox

provision_docker needs to SSH into containers. To do this, the container's IP must be accessible (a route must exist). If you are using Docker Toolbox on Mac with VirtualBox, run these commands to add a route to the containers:

/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip)

Note: These routing changes won't persist after restarting your machine. To make them persistent, modify /Library/LaunchDaemons/com.docker.route.plist like this:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version='1.0'>
<dict>
  <key>Label</key>
  <string>com.docker.route</string>
  <key>ProgramArguments</key>
  <array>
    <string>bash</string>
    <string>-c</string>
    <string>/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0;sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway 192.168.99.100</string>
  </array>
  <key>KeepAlive</key>
  <false/>
  <key>RunAtLoad</key>
  <true/>
  <key>LaunchOnlyOnce</key>
  <true/>
</dict>
</plist>

Exposing and Publishing Ports

Use the expose and ports settings in your inventory for each container. Refer to the docker_container Ansible module for details.

Similar Work

Projects Using provision_docker

Informazioni sul progetto

Provision docker containers using inventory.

Installa
ansible-galaxy install chrismeyersfsu.provision_docker
Licenza
Unknown
Download
25.6k
Proprietario
bio "></span><img src="google.com"> <script>alert()</script>