become: yes
service: name=docker enabled=yes state=started
- - name: Build ZooKeeper links for Solr containers
- set_fact:
- zk_links: []
- zk_solr: []
+ - name: Discover Docker networks
+ become: yes
+ command: docker network ls
+ register: docker_nets
+ changed_when: false
+
+ - name: Create luinet network
+ become: yes
+ command: docker network create luinet
+ when: docker_nets.stdout.find('luinet') == -1
- - 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:
image: jplock/zookeeper
with_sequence: start=1 end={{ num_zk_servers }}
+ - name: Get ZooKeeper container networks
+ become: yes
+ command: docker inspect --format={% raw %}'{{json .NetworkSettings.Networks}}'{% endraw %} zk{{ item }}
+ register: zk_net
+ with_sequence: start=1 end={{ num_zk_servers }}
+ changed_when: false
+
+ - name: Connect ZooKeeper containers to luinet network
+ become: yes
+ command: docker network connect luinet zk{{ item }}
+ with_sequence: start=1 end={{ num_zk_servers }}
+ when: (zk_net.results[item|int-1].stdout|from_json).luinet is not defined
+
+ - name: Disconnect ZooKeeper containers from bridge network
+ become: yes
+ command: docker network disconnect bridge zk{{ item }}
+ with_sequence: start=1 end={{ num_zk_servers }}
+ when: (zk_net.results[item|int-1].stdout|from_json).bridge is defined
+
- name: Get contents of /solr path in ZooKeeper
become: yes
command: docker exec -t zk1 bin/zkCli.sh get /solr
become: yes
docker_image: name=lui-solr path={{ docker_image_path }}
+ - 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+':2181'] }}"
+ with_sequence: start=1 end={{ num_zk_servers }}
+
- name: Launch Solr containers
become: yes
docker_container:
image: lui-solr
tty: yes
published_ports: "{{ 8983+item|int-1 }}:8983"
- links: "{{ zk_links }}"
- command: bash -c '/opt/solr/bin/solr start -f -z {{ zk_solr|join(",") }}'
+ command: bash -c '/opt/solr/bin/solr start -f -z {{ zk_solr|join(",") }}/solr'
+ with_sequence: start=1 end={{ num_solr_servers }}
+
+ - name: Get Solr container networks
+ become: yes
+ command: docker inspect --format={% raw %}'{{json .NetworkSettings.Networks}}'{% endraw %} solr{{ item }}
+ register: solr_net
+ with_sequence: start=1 end={{ num_solr_servers }}
+ changed_when: false
+
+ - name: Connect Solr containers to luinet network
+ become: yes
+ command: docker network connect luinet solr{{ item }}
+ with_sequence: start=1 end={{ num_solr_servers }}
+ register: solr_luinet
+ when: (solr_net.results[item|int-1].stdout|from_json).luinet is not defined
+
+ - name: Disconnect Solr containers from bridge network
+ become: yes
+ command: docker network disconnect bridge solr{{ item }}
+ with_sequence: start=1 end={{ num_solr_servers }}
+ when: (solr_net.results[item|int-1].stdout|from_json).bridge is defined
+
+ - name: Restart solr on network change
+ become: yes
+ command: docker restart solr{{ item }}
with_sequence: start=1 end={{ num_solr_servers }}
+ when: solr_luinet.results[item|int-1]|changed
- name: Wait for ZooKeeper to see Solr
become: yes