From 25ade8615d77bbd9d5d73edd1fba984b4ddd3b70 Mon Sep 17 00:00:00 2001 From: Ilya Date: Sun, 17 Dec 2017 21:32:54 +0300 Subject: [PATCH] Extracted hardcoded zookeeper ports into vars (#77) * Extracted hardcoded zookeeper ports into vars * Set proper variable for test --- README.md | 1 + defaults/main.yml | 1 + templates/zoo.cfg.j2 | 6 +++--- tests/test.yml | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 93d3425..f8c5d18 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ sync_limit: 2 tick_time: 2000 zookeeper_autopurge_purgeInterval: 0 zookeeper_autopurge_snapRetainCount: 10 +zookeeper_cluster_ports: "2888:3888" data_dir: /var/lib/zookeeper log_dir: /var/log/zookeeper diff --git a/defaults/main.yml b/defaults/main.yml index ae6e86f..7b6400c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,6 +19,7 @@ sync_limit: 2 tick_time: 2000 zookeeper_autopurge_purgeInterval: 0 zookeeper_autopurge_snapRetainCount: 10 +zookeeper_cluster_ports: "2888:3888" data_dir: /var/lib/zookeeper log_dir: /var/log/zookeeper diff --git a/templates/zoo.cfg.j2 b/templates/zoo.cfg.j2 index 36bf950..a5e8fb6 100644 --- a/templates/zoo.cfg.j2 +++ b/templates/zoo.cfg.j2 @@ -13,11 +13,11 @@ autopurge.snapRetainCount={{ zookeeper_autopurge_snapRetainCount }} {% for server in zookeeper_hosts %} {% if server.host is defined %} {% if server.ip is defined %} -server.{{server.id}}={{server.ip}}:2888:3888 +server.{{server.id}}={{server.ip}}:{{zookeeper_cluster_ports}} {% else %} -server.{{server.id}}={{server.host}}:2888:3888 +server.{{server.id}}={{server.host}}:{{zookeeper_cluster_ports}} {% endif %} {% else %} -server.{{loop.index}}={{server}}:2888:3888 +server.{{loop.index}}={{server}}:{{zookeeper_cluster_ports}} {% endif %} {% endfor %} diff --git a/tests/test.yml b/tests/test.yml index 23f55e8..cf59ee2 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -78,6 +78,7 @@ vars: zookeeper_version: 3.4.11 zookeeper_dir: /opt/zookeeper-{{zookeeper_version}} + zookeeper_cluster_ports: "2888:3888" tasks: # Expecting myid to be 2 as defined in zookeeper_hosts variable - shell: "grep 2 /var/lib/zookeeper/myid" @@ -85,7 +86,7 @@ failed_when: status.rc != 0 # Expecting zoo.cfg to include serve definition with custom IP - - shell: "grep 'server.2=192.168.0.1:2888:3888' {{ zookeeper_dir }}/conf/zoo.cfg" + - shell: "grep 'server.2=192.168.0.1:{{ zookeeper_cluster_ports }}' {{ zookeeper_dir }}/conf/zoo.cfg" register: status failed_when: status.rc != 0