More work towards SolrCloud/Docker.
[lui-solr.git] / docker / docker-deploy.yml
index 628095a..ca0d4ab 100644 (file)
       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
+      become: yes
       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: Get contents of /solr path in ZooKeeper
+      become: yes
+      command: docker exec -t zk1 bin/zkCli.sh get /solr
+      register: zk1_solr
 
-    - name: Attach ZooKeeper to luinet network
-      command: docker network connect luinet zk1
-      when: (zk1_networks.stdout|from_json).luinet is not defined
+    - name: Create /solr path in ZooKeeper
+      become: yes
+      command: docker exec -t zk1 bin/zkCli.sh create /solr []
+      when: zk1_solr.stdout.find('Node does not exist') != -1
 
-    - name: Detach ZooKeeper from bridge network
-      command: docker network disconnect bridge zk1
-      when: (zk1_networks.stdout|from_json).bridge is defined
+# Separate paths for setting up Solr nodes
 
 - hosts: dev
   roles:
   roles:
     - prod
 
-- hosts: all
+# Back to everyone
 
+- 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'
+    - name: Launch Solr1
+      become: yes
+      docker_container:
+        name: solr1
+        image: lui-solr
+        tty: yes
+        published_ports: 8983:8983
+        links: zk1:ZK1
+        command: bash -c '/opt/solr/bin/solr start -f -z $ZK1_PORT_2181_TCP_ADDR:$ZK1_PORT_2181_TCP_PORT/solr'
+
+    - name: Launch Solr2
+      become: yes
+      docker_container:
+        name: solr2
+        image: lui-solr
+        tty: yes
+        published_ports: 8984:8983
+        links: zk1:ZK1
+        command: bash -c '/opt/solr/bin/solr start -f -z $ZK1_PORT_2181_TCP_ADDR:$ZK1_PORT_2181_TCP_PORT/solr'
+
+    ### HERE I AM ###
+    # wait for ZooKeeper to see all the solr nodes before proceeding
+    # look at Ansible until module
+
+    - name: Check lui collection
+      become: yes
+      command: docker exec -t zk1 bin/zkCli.sh ls /solr/collections
+      register: lui_collection
+
+    - name: Create lui collection
+      become: yes
+      command: docker exec -t solr1 bin/solr create -c lui -d /opt/solr/lui-solr -shards 2
+      when: (lui_collection.stdout_lines|last).find('lui') == -1
+