Skip to content

Commit

Permalink
Changed schema for clickhouse clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Boiko committed Feb 13, 2020
1 parent cc23474 commit 1840615
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ansible-clickhouse [![Build Status](https://travis-ci.org/AlexeySetevoi/ansible-clickhouse.svg?branch=master)](https://travis-ci.org/AlexeySetevoi/ansible-clickhouse)
ansible-clickhouse [![Build Status](https://travis-ci.com/dmytroboiko/ansible-clickhouse.svg?branch=master)](https://travis-ci.com/dmytroboiko/ansible-clickhouse)
=========

Simple clickhouse-server deploy and management role.
Expand Down Expand Up @@ -211,9 +211,12 @@ Including an example of how to use your role (for instance, with variables passe
- { name: testAttrName, type: UInt32, null_value: 0 }
test2:
name: test_dict
odbc_source:
connection_string: "DSN=testdb"
source_table: "dict_source"
mysql_source:
host: "localhost"
user: "clickhouse"
password: ""
db: "management"
table: "customers"
lifetime:
min: 300
max: 360
Expand All @@ -228,11 +231,18 @@ Including an example of how to use your role (for instance, with variables passe
- { name: testu1 }
- { name: testu2, state:present }
- { name: testu3, state:absent }
clickhouse_shards:
your_shard_name:
- { host: "db_host_1", port: 9000 }
- { host: "db_host_2", port: 9000 }
- { host: "db_host_3", port: 9000 }
clickhouse_clusters:
your_cluster_name:
- weight: 1
internal_replication: false
servers:
- { host: "db_host_1", port: 9000 }
- { host: "db_host_2", port: 9000 }
- weight: 1
internal_replication: false
servers:
- { host: "db_host_3", port: 9000 }
- { host: "db_host_4", port: 9000 }
clickhouse_zookeeper_nodes:
- { host: "zoo_host_1", port: 2181 }
- { host: "zoo_host_2", port: 2181 }
Expand Down
2 changes: 1 addition & 1 deletion tasks/config_sys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
group: clickhouse
notify: restart-ch
become: true
when: clickhouse_shards is defined
when: clickhouse_clusters is defined

- name: Config | Generate macros config
template:
Expand Down
17 changes: 12 additions & 5 deletions templates/remote_servers.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
<!-- {{ ansible_managed }} -->
<yandex>
<remote_servers>
{% for shard_name, replicas in clickhouse_shards.iteritems() %}
<{{ shard_name }}>
{% for cluster_name, shards in clickhouse_clusters.iteritems() %}
<{{ cluster_name }}>
{% for shard in shards %}
<shard>
<internal_replication>true</internal_replication>
{% for replica in replicas %}
{% if shard.weight is defined %}
<weight>{{ shard.weight }}</weight>
{% endif %}
{% if shard.internal_replication is defined %}
<internal_replication>{{ shard.internal_replication }}</internal_replication>
{% endif %}
{% for replica in shard.servers %}
<replica>
<host>{{ replica['host'] }}</host>
<port>{{ replica['port'] | default(9000) }}</port>
</replica>
{% endfor %}
</shard>
</{{ shard_name }}>
{% endfor %}
</{{ cluster_name }}>
{% endfor %}
</remote_servers>
</yandex>
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
attributes:
- { name: testAttrName, type: String, null_value: "" }
roles:
- ansible-clickhouse
- ansible-clickhouse

0 comments on commit 1840615

Please sign in to comment.