Skip to content

Commit

Permalink
Extracted hardcoded zookeeper ports into vars (#77)
Browse files Browse the repository at this point in the history
* Extracted hardcoded zookeeper ports into vars

* Set proper variable for test
  • Loading branch information
RunsFor authored and ernestas-poskus committed Dec 17, 2017
1 parent 7bd414a commit 25ade86
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions templates/zoo.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
3 changes: 2 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@
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"
register: status
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

0 comments on commit 25ade86

Please sign in to comment.