diff --git a/templates/instances.xml.j2 b/templates/instances.xml.j2
index e4cfdc3..e970be5 100644
--- a/templates/instances.xml.j2
+++ b/templates/instances.xml.j2
@@ -1,118 +1,24 @@
+
-
+{% for clusters_name, shards_name in clickhouse_clusters.items() | list %}
+ <{{ clusters_name }}>
+{% for shard_name, replicas in shards_name.items() %}
true
- {% for node_hostname in groups['clickhouse_ip-shard01'] %}
+{% for replica in replicas %}
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
+ {{ replica['host'] }}
+ {{ replica['port'] }}
+ {{ clickhouse_distributed_user }}
-
- {% endfor %}
+
+{% endfor %}
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard02'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard03'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard04'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard05'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard06'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard07'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard08'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard09'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
- true
- {% for node_hostname in groups['clickhouse_ip-shard10'] %}
-
- {{ node_hostname }}
- {{ clickhouse_tcp_port }}
- app_sib
-
-
- {% endfor %}
-
-
+{% endfor %}
+ {{ clusters_name }}>
+{% endfor %}
diff --git a/templates/macros.xml.j2 b/templates/macros.xml.j2
index a59d8a7..c96360d 100644
--- a/templates/macros.xml.j2
+++ b/templates/macros.xml.j2
@@ -2,38 +2,9 @@
- {{ clickhouse_display_name | default('clickhouse') }}
- {% if inventory_hostname in groups['clickhouse_shard01'] %}
- 01
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard02'] %}
- 02
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard03'] %}
- 03
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard04'] %}
- 04
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard05'] %}
- 05
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard06'] %}
- 06
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard07'] %}
- 07
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard08'] %}
- 08
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard09'] %}
- 09
- {% endif %}
- {% if inventory_hostname in groups['clickhouse_shard10'] %}
- 10
- {% endif %}
+ {{ cluster }}
+ {{ shard }}
{{ inventory_hostname }}
- distributed_cluster
+ {{ distributed_cluster }}