Ansible plays to build dev environment with zookeeper ensemble. ha
authorWayne Schneider <wayne@indexdata.com>
Tue, 16 Aug 2016 15:57:35 +0000 (10:57 -0500)
committerWayne Schneider <wayne@indexdata.com>
Tue, 16 Aug 2016 15:57:35 +0000 (10:57 -0500)
docker/docker-deploy.yml
docker/group_vars/dev
docker/zookeeper/configuration.xsl [new file with mode: 0644]
docker/zookeeper/log4j.properties [new file with mode: 0644]
docker/zookeeper/zoo.cfg [new file with mode: 0644]

index 20578b5..dc58055 100644 (file)
       command: docker network create luinet
       when: docker_nets.stdout.find('luinet') == -1
 
+    - name: Copy ZooKeeper config if not present
+      become: yes
+      copy: src=zookeeper dest=/etc/masterkey/lui/ force=no
+
+    - name: Create ZooKeeper dataDirs
+      become: yes
+      file: path=/var/lib/masterkey/lui/zookeeper/zk{{ item }} state=directory
+      with_sequence: start=1 end={{ num_zk_servers }}
+
     - name: Launch ZooKeeper containers
       become: yes
       docker_container:
         name: zk{{ item }}
         image: jplock/zookeeper
+        volumes:
+          - /etc/masterkey/lui/zookeeper:/opt/zookeeper/conf
+          - /var/lib/masterkey/lui/zookeeper/zk{{ item }}:/tmp/zookeeper
       with_sequence: start=1 end={{ num_zk_servers }}
 
     - name: Get ZooKeeper container networks
       with_sequence: start=1 end={{ num_zk_servers }}
       when: (zk_net.results[item|int-1].stdout|from_json).bridge is defined
 
+    - name: Create ZooKeeper myid files
+      become: yes
+      copy: content={{ item }} dest=/var/lib/masterkey/lui/zookeeper/zk{{ item }}/myid
+      with_sequence: start=1 end={{ num_zk_servers }}
+      when: num_zk_servers > 1
+
+    # Note - this will not remove servers from config
+    - name: Update zoo.cfg for ensemble
+      become: yes
+      lineinfile: dest=/etc/masterkey/lui/zookeeper/zoo.cfg line="server.{{ item }}=zk{{ item }}:2888:3888"
+      register: zk_conf
+      with_sequence: start=1 end={{ num_zk_servers }}
+      when: num_zk_servers > 1
+
+    - name: Restart ZooKeeper
+      become: yes
+      command: docker restart zk{{ item }}
+      with_sequence: start=1 end={{ num_zk_servers }}
+      when: zk_conf|changed
+      
     - name: Get contents of /solr path in ZooKeeper
       become: yes
       command: docker exec -t zk1 bin/zkCli.sh get /solr
 
     - name: Build the lui-solr image
       become: yes
-      docker_image: name=lui-solr path={{ docker_image_path }}
+      docker_image: name=lui-solr path={{ solr_image_path }}
 
-    - name: Build ZooKeeper links for Solr containers
+    - name: Build -z string for Solr
       set_fact:
-    #     zk_links: []
-        zk_solr: []
-
-    - set_fact:
-    #     zk_links: "{{ zk_links + ['zk'+item+':ZK'+item] }}"
-        zk_solr: "{{ zk_solr + ['zk'+item+':2181'] }}"
+        zk_solr: "{{ zk_solr|default([]) + ['zk'+item+':2181'] }}"
       with_sequence: start=1 end={{ num_zk_servers }}
 
     - name: Launch Solr containers
index a95559e..8d4a956 100644 (file)
@@ -1,7 +1,8 @@
 ---
 docker_users:
   - vagrant
-docker_image_path: /vagrant/docker/solr
+solr_image_path: /vagrant/docker/solr
+zookeeper_image_path: /vagrant/docker/zookeeper
 num_solr_servers: 2
-num_zk_servers: 1
+num_zk_servers: 3
 num_shards: 2
diff --git a/docker/zookeeper/configuration.xsl b/docker/zookeeper/configuration.xsl
new file mode 100644 (file)
index 0000000..377cdbe
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html"/>
+<xsl:template match="configuration">
+<html>
+<body>
+<table border="1">
+<tr>
+ <td>name</td>
+ <td>value</td>
+ <td>description</td>
+</tr>
+<xsl:for-each select="property">
+<tr>
+  <td><a name="{name}"><xsl:value-of select="name"/></a></td>
+  <td><xsl:value-of select="value"/></td>
+  <td><xsl:value-of select="description"/></td>
+</tr>
+</xsl:for-each>
+</table>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/docker/zookeeper/log4j.properties b/docker/zookeeper/log4j.properties
new file mode 100644 (file)
index 0000000..9825970
--- /dev/null
@@ -0,0 +1,58 @@
+# Define some default values that can be overridden by system properties
+zookeeper.root.logger=INFO, CONSOLE
+zookeeper.console.threshold=INFO
+zookeeper.log.dir=.
+zookeeper.log.file=zookeeper.log
+zookeeper.log.threshold=DEBUG
+zookeeper.tracelog.dir=.
+zookeeper.tracelog.file=zookeeper_trace.log
+
+#
+# ZooKeeper Logging Configuration
+#
+
+# Format is "<default threshold> (, <appender>)+
+
+# DEFAULT: console appender only
+log4j.rootLogger=${zookeeper.root.logger}
+
+# Example with rolling log file
+#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
+
+# Example with rolling log file and tracing
+#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
+
+#
+# Log INFO level and above messages to the console
+#
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
+
+#
+# Add ROLLINGFILE to rootLogger to get log file output
+#    Log DEBUG level and above messages to a log file
+log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
+log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
+
+# Max log file size of 10MB
+log4j.appender.ROLLINGFILE.MaxFileSize=10MB
+# uncomment the next line to limit number of backup files
+#log4j.appender.ROLLINGFILE.MaxBackupIndex=10
+
+log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
+
+
+#
+# Add TRACEFILE to rootLogger to get log file output
+#    Log DEBUG level and above messages to a log file
+log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
+log4j.appender.TRACEFILE.Threshold=TRACE
+log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
+
+log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
+### Notice we are including log4j's NDC here (%x)
+log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
diff --git a/docker/zookeeper/zoo.cfg b/docker/zookeeper/zoo.cfg
new file mode 100644 (file)
index 0000000..a5a2c0b
--- /dev/null
@@ -0,0 +1,28 @@
+# The number of milliseconds of each tick
+tickTime=2000
+# The number of ticks that the initial 
+# synchronization phase can take
+initLimit=10
+# The number of ticks that can pass between 
+# sending a request and getting an acknowledgement
+syncLimit=5
+# the directory where the snapshot is stored.
+# do not use /tmp for storage, /tmp here is just 
+# example sakes.
+dataDir=/tmp/zookeeper
+# the port at which the clients will connect
+clientPort=2181
+# the maximum number of client connections.
+# increase this if you need to handle more clients
+#maxClientCnxns=60
+#
+# Be sure to read the maintenance section of the 
+# administrator guide before turning on autopurge.
+#
+# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
+#
+# The number of snapshots to retain in dataDir
+#autopurge.snapRetainCount=3
+# Purge task interval in hours
+# Set to "0" to disable auto purge feature
+#autopurge.purgeInterval=1