X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=docker%2Fdocker-deploy.yml;h=9acbd962c953f2446611dbc3aba3d489db356cc8;hb=0bd368eca6e38f70c6d12b0b9bf10f8fd2f19ae4;hp=ca0d4ab3590b151877c4818a0c926dcbdf32517d;hpb=664635ceab85dcb4b9624bcce816a3da51e00b26;p=lui-solr.git diff --git a/docker/docker-deploy.yml b/docker/docker-deploy.yml index ca0d4ab..9acbd96 100644 --- a/docker/docker-deploy.yml +++ b/docker/docker-deploy.yml @@ -1,5 +1,5 @@ --- -# deploy a Docker server with 1 Zookeeper, 3 Solr, 1 HAProxy +# deploy a Docker server with Zookeeper, Solr, HAProxy - hosts: all tasks: @@ -43,65 +43,65 @@ become: yes service: name=docker enabled=yes state=started - - name: Launch ZooKeeper + - name: Build ZooKeeper links for Solr containers + set_fact: + zk_links: [] + zk_solr: [] + + - set_fact: + zk_links: "{{ zk_links + ['zk'+item+':ZK'+item] }}" + zk_solr: "{{ zk_solr + ['$ZK'+item+'_PORT_2181_TCP_ADDR:$ZK'+item+'_PORT_2181_TCP_PORT/solr'] }}" + with_sequence: start=1 end={{ num_zk_servers }} + + - name: Launch ZooKeeper containers become: yes - docker_container: name=zk1 image=jplock/zookeeper + docker_container: + name: zk{{ item }} + image: jplock/zookeeper + with_sequence: start=1 end={{ num_zk_servers }} - name: Get contents of /solr path in ZooKeeper become: yes command: docker exec -t zk1 bin/zkCli.sh get /solr register: zk1_solr + changed_when: false - 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 -# Separate paths for setting up Solr nodes - -- hosts: dev - roles: - - dev - -- hosts: prod - roles: - - prod - -# Back to everyone - -- hosts: all - tasks: - - name: Launch Solr1 + - name: Build the lui-solr image 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' + docker_image: name=lui-solr path={{ docker_image_path }} - - name: Launch Solr2 + - name: Launch Solr containers become: yes docker_container: - name: solr2 + name: solr{{ item }} 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' + published_ports: "{{ 8983+item|int-1 }}:8983" + links: "{{ zk_links }}" + command: bash -c '/opt/solr/bin/solr start -f -z {{ zk_solr|join(",") }}' + with_sequence: start=1 end={{ num_solr_servers }} - ### HERE I AM ### - # wait for ZooKeeper to see all the solr nodes before proceeding - # look at Ansible until module + - name: Wait for ZooKeeper to see Solr + become: yes + command: docker exec -t zk1 bin/zkCli.sh get /solr/live_nodes + register: solr_nodes + until: solr_nodes.stdout.find('numChildren = {{ num_solr_servers }}') != -1 + retries: 3 + delay: 2 + changed_when: false - name: Check lui collection become: yes command: docker exec -t zk1 bin/zkCli.sh ls /solr/collections register: lui_collection + changed_when: false - name: Create lui collection become: yes - command: docker exec -t solr1 bin/solr create -c lui -d /opt/solr/lui-solr -shards 2 + command: docker exec -t solr1 bin/solr create -c lui -d /opt/solr/lui-solr -shards 2 -replicationFactor 2 when: (lui_collection.stdout_lines|last).find('lui') == -1 -