Skip to content

Commit

Permalink
Configurable zookeeper environment vars (#39)
Browse files Browse the repository at this point in the history
* configurable zookeeper environment vars (useful p.eg to configure logging to file)

* do not write the (empty) zookeeper-env.sh file if the zookeeper_env dict is empty

* extract new zookeeper-env feature into common include
  • Loading branch information
lhoss authored and ernestas-poskus committed Aug 12, 2016
1 parent 6a9b545 commit a24b32c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ zookeeper_tarball_dir: /opt/src
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
id: 1

# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh
zookeeper_env: {}
7 changes: 7 additions & 0 deletions tasks/common-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Configure zookeeper-env.sh
template: src=zookeeper-env.sh.j2 dest={{ zookeeper_dir }}/conf/zookeeper-env.sh owner=zookeeper group=zookeeper
tags: deploy
notify:
- Restart zookeeper
when: zookeeper_env is defined and zookeeper_env|length > 0
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@

- include: RedHat.yml
when: ansible_os_family == 'RedHat'

- include: common-config.yml
2 changes: 1 addition & 1 deletion tasks/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
notify:
- Restart zookeeper

- name: Configure zookeeper
- name: Configure zookeeper zoo.cfg
template: src=zoo.cfg.j2 dest={{ zookeeper_dir }}/conf/zoo.cfg owner=zookeeper group=zookeeper
tags: deploy
notify:
Expand Down
5 changes: 5 additions & 0 deletions templates/zookeeper-env.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if zookeeper_env is defined %}
{% for key, value in zookeeper_env.items() | sort %}
{{key}}={{value}}
{% endfor %}
{% endif %}

0 comments on commit a24b32c

Please sign in to comment.