Skip to content

Commit 87bbce5

Browse files
Merge pull request #82 from StuartApp/custom_zookeper_hosts
Customize own hostname with a new variable
2 parents 1416185 + 84c1357 commit 87bbce5

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ zookeeper_dir: /opt/zookeeper-{{zookeeper_version}} # or /usr/share/zookeeper wh
6161
zookeeper_conf_dir: {{zookeeper_dir}} # or /etc/zookeeper when zookeeper_debian_apt_install is true
6262
zookeeper_tarball_dir: /opt/src
6363

64+
zookeeper_hosts_hostname: "{{inventory_hostname}}"
6465
# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]})
6566
zookeeper_hosts:
66-
- host: "{{inventory_hostname}}" # the machine running
67+
- host: "{{zookeeper_hosts_hostname}}" # the machine running
6768
id: 1
6869

6970
# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh

defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ zookeeper_tarball_dir: /opt/src
3232
zookeeper_rolling_log_file_max_size: 10MB
3333
zookeeper_max_rolling_log_file_count: 10
3434

35+
zookeeper_hosts_hostname: "{{inventory_hostname}}"
3536
# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]})
3637
zookeeper_hosts:
37-
- host: "{{inventory_hostname}}" # the machine running
38+
- host: "{{zookeeper_hosts_hostname}}" # the machine running
3839
id: 1
3940

4041
# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh

templates/myid.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{% for server in zookeeper_hosts %}
22
{% if server.host is defined %}
3-
{% if server.host == inventory_hostname %}
3+
{% if server.host == zookeeper_hosts_hostname %}
44
{{ server.id }}
55
{% endif %}
66
{% else %}
7-
{% if server == inventory_hostname %}
7+
{% if server == zookeeper_hosts_hostname %}
88
{{ loop.index }}
99
{% endif %}
1010
{% endif %}

tests/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
roles:
2424
- role: role_under_test
2525
zookeeper_hosts:
26-
- host: "{{inventory_hostname}}" # the machine running
26+
- host: "{{zookeeper_hosts_hostname}}" # the machine running
2727
id: 2
2828

2929
- hosts: localhost
@@ -45,7 +45,7 @@
4545
roles:
4646
- role: role_under_test
4747
zookeeper_hosts:
48-
- "{{inventory_hostname}}"
48+
- "{{zookeeper_hosts_hostname}}"
4949

5050
- hosts: localhost
5151
connection: local
@@ -68,7 +68,7 @@
6868
zookeeper_version: 3.4.11
6969
zookeeper_dir: /opt/zookeeper-{{zookeeper_version}}
7070
zookeeper_hosts:
71-
- host: "{{inventory_hostname}}" # the machine running
71+
- host: "{{zookeeper_hosts_hostname}}" # the machine running
7272
ip: '192.168.0.1'
7373
id: 2
7474

0 commit comments

Comments
 (0)