--- /dev/null
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+# Build a VM to serve as a Docker server
+
+Vagrant.configure(2) do |config|
+ # Target platform is Debian/jessie
+ config.vm.box = "debian/contrib-jessie64"
+
+ # Give me a little headroom here
+ config.vm.provider "virtualbox" do |vb|
+ vb.memory = 4096
+ vb.cpus = 2
+ end
+
+ # Disable the default share
+ # Share the project folder on /vagrant
+ config.vm.synced_folder ".", "/vagrant", disabled: true
+ config.vm.synced_folder "..", "/vagrant"
+
+ # Set up port forwarding
+ config.vm.network "forwarded_port", guest: 8983, host: 8983
+
+ config.vm.provision "ansible" do |ansible|
+ ansible.playbook = "docker-deploy.yml"
+ ansible.groups = {
+ "dev" => ["default"],
+ }
+ end
+end
--- /dev/null
+---
+# deploy a Docker server with 1 Zookeeper, 3 Solr, 1 HAProxy
+- hosts: all
+
+ tasks:
+ - name: Install prereqs from apt
+ become: yes
+ apt: name={{ item }}
+ with_items:
+ - apt-transport-https
+ - ca-certificates
+ - python-virtualenv
+ - python-pip
+
+ - name: Install prereqs from pip
+ become: yes
+ pip: name={{ item }}
+ with_items:
+ - docker-py
+
+ - name: Install apt key for Docker
+ become: yes
+ apt_key: id=58118E89F3A912897C070ADBF76221572C52609D keyserver=hkp://p80.pool.sks-keyservers.net:80
+
+ - name: Install apt repository for Docker
+ become: yes
+ apt_repository: repo="deb https://apt.dockerproject.org/repo debian-jessie main"
+
+ - name: Create docker group
+ become: yes
+ group: name=docker
+
+ - name: Add users to docker group
+ become: yes
+ user: name={{ item }} groups=docker
+ with_items: "{{ docker_users }}"
+
+ - name: Install Docker Engine
+ become: yes
+ apt: name=docker-engine
+
+ - name: Start up Docker
+ become: yes
+ service: name=docker enabled=yes state=started
+
+ - name: Check for luinet network
+ command: docker network ls -f name=luinet -q
+ register: luinet
+
+ - name: Create luinet network
+ command: docker network create luinet
+ when: luinet.stdout == ""
+
+ - name: Launch ZooKeeper
+ docker_container: name=zk1 image=jplock/zookeeper
+
+ - name: Get networks for ZooKeeper
+ shell: "docker inspect --format={% raw %}'{{json .NetworkSettings.Networks}}'{% endraw %} zk1"
+ register: zk1_networks
+
+ - name: Attach ZooKeeper to luinet network
+ command: docker network connect luinet zk1
+ when: (zk1_networks.stdout|from_json).luinet is not defined
+
+ - name: Detach ZooKeeper from bridge network
+ command: docker network disconnect bridge zk1
+ when: (zk1_networks.stdout|from_json).bridge is defined
+
+- hosts: dev
+ roles:
+ - dev
+
+- hosts: prod
+ roles:
+ - prod
+
+- hosts: all
+
+ tasks:
+ - name: Get networks for Solr
+ shell: "docker inspect --format={% raw %}'{{json .NetworkSettings.Networks}}'{% endraw %} solr1"
+ register: solr1_networks
+
+ - name: Attach Solr to luinet network
+ command: docker network connect luinet solr1
+ when: (solr1_networks.stdout|from_json).luinet is not defined
+
+ - name: Detach Solr from bridge network
+ command: docker network disconnect bridge solr1
+ when: (solr1_networks.stdout|from_json).bridge is defined
+
+ # - name: Create Solr container
+ # docker_container:
+ # name: solr1
+ # tty: yes
+ # published_ports: 8983:8983
+ # #volumes: /vagrant/conf/solr/solr-home:/opt/solr/server/solr
+ # command: bash -c '/opt/solr/bin/solr start -f -z zk1:2181'