Skip to content

Commit

Permalink
Customize own hostname with a new variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jordiclariana committed Apr 6, 2018
1 parent 31a3cab commit 84c1357
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ zookeeper_dir: /opt/zookeeper-{{zookeeper_version}} # or /usr/share/zookeeper wh
zookeeper_conf_dir: {{zookeeper_dir}} # or /etc/zookeeper when zookeeper_debian_apt_install is true
zookeeper_tarball_dir: /opt/src

zookeeper_hosts_hostname: "{{inventory_hostname}}"
# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]})
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
- host: "{{zookeeper_hosts_hostname}}" # the machine running
id: 1

# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh
Expand Down
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ zookeeper_tarball_dir: /opt/src
zookeeper_rolling_log_file_max_size: 10MB
zookeeper_max_rolling_log_file_count: 10

zookeeper_hosts_hostname: "{{inventory_hostname}}"
# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]})
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
- host: "{{zookeeper_hosts_hostname}}" # the machine running
id: 1

# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh
Expand Down
4 changes: 2 additions & 2 deletions templates/myid.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% for server in zookeeper_hosts %}
{% if server.host is defined %}
{% if server.host == inventory_hostname %}
{% if server.host == zookeeper_hosts_hostname %}
{{ server.id }}
{% endif %}
{% else %}
{% if server == inventory_hostname %}
{% if server == zookeeper_hosts_hostname %}
{{ loop.index }}
{% endif %}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
roles:
- role: role_under_test
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
- host: "{{zookeeper_hosts_hostname}}" # the machine running
id: 2

- hosts: localhost
Expand All @@ -45,7 +45,7 @@
roles:
- role: role_under_test
zookeeper_hosts:
- "{{inventory_hostname}}"
- "{{zookeeper_hosts_hostname}}"

- hosts: localhost
connection: local
Expand All @@ -68,7 +68,7 @@
zookeeper_version: 3.4.11
zookeeper_dir: /opt/zookeeper-{{zookeeper_version}}
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
- host: "{{zookeeper_hosts_hostname}}" # the machine running
ip: '192.168.0.1'
id: 2

Expand Down

0 comments on commit 84c1357

Please sign in to comment.