From a24b32ce853172bd323ada13fa86e3dbfd4f14d2 Mon Sep 17 00:00:00 2001 From: Laurent Hoss Date: Fri, 12 Aug 2016 10:30:35 +0200 Subject: [PATCH] Configurable zookeeper environment vars (#39) * 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 --- defaults/main.yml | 3 +++ tasks/common-config.yml | 7 +++++++ tasks/main.yml | 2 ++ tasks/tarball.yml | 2 +- templates/zookeeper-env.sh.j2 | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tasks/common-config.yml create mode 100644 templates/zookeeper-env.sh.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 1b3ee8a..b8c65bc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: {} diff --git a/tasks/common-config.yml b/tasks/common-config.yml new file mode 100644 index 0000000..8f0c9ae --- /dev/null +++ b/tasks/common-config.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 965e43b..7e15ed0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,3 +8,5 @@ - include: RedHat.yml when: ansible_os_family == 'RedHat' + +- include: common-config.yml diff --git a/tasks/tarball.yml b/tasks/tarball.yml index 44b7c84..ecb8502 100644 --- a/tasks/tarball.yml +++ b/tasks/tarball.yml @@ -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: diff --git a/templates/zookeeper-env.sh.j2 b/templates/zookeeper-env.sh.j2 new file mode 100644 index 0000000..7cfd9f1 --- /dev/null +++ b/templates/zookeeper-env.sh.j2 @@ -0,0 +1,5 @@ +{% if zookeeper_env is defined %} +{% for key, value in zookeeper_env.items() | sort %} +{{key}}={{value}} +{% endfor %} +{% endif %}