diff --git a/README.md b/README.md index 1a21498..202c824 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,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 diff --git a/defaults/main.yml b/defaults/main.yml index ecf0222..b8feb26 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,9 +32,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 diff --git a/templates/myid.j2 b/templates/myid.j2 index a0122d9..9de7bc1 100644 --- a/templates/myid.j2 +++ b/templates/myid.j2 @@ -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 %} diff --git a/tests/test.yml b/tests/test.yml index cf59ee2..fec48c8 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -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 @@ -45,7 +45,7 @@ roles: - role: role_under_test zookeeper_hosts: - - "{{inventory_hostname}}" + - "{{zookeeper_hosts_hostname}}" - hosts: localhost connection: local @@ -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