AlexeySetevoi.clickhouse
ansible-clickhouse
A simple role for deploying and managing ClickHouse server. Feel free to report issues or contribute.
Role Variables
You can specify a version for ClickHouse (or use * for the latest). Downgrading is not supported.
clickhouse_version: "19.11.3.11"
Manage listening ports:
clickhouse_http_port: 8123
clickhouse_tcp_port: 9000
clickhouse_interserver_http: 9009
Add custom listening IPs beyond the defaults:
clickhouse_listen_host_custom:
- "192.168.0.1"
Set TTL for query logs:
clickhouse_query_log_ttl: 'event_date + INTERVAL 7 DAY DELETE'
Set TTL for query thread logs:
clickhouse_query_thread_log_ttl: 'event_date + INTERVAL 7 DAY DELETE'
Or specify IPs directly, for example to listen on all IPv4 and IPv6 addresses:
clickhouse_listen_host:
- "::"
Create custom profiles:
clickhouse_profiles_custom:
my_custom_profile:
max_memory_usage: 10000000000
use_uncompressed_cache: 0
load_balancing: random
my_super_param: 9000
You can create custom users:
clickhouse_users_custom:
- { name: "testuser",
password_sha256_hex: "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
networks: "{{ clickhouse_networks_default }}",
profile: "default",
quota: "default",
dbs: [ testu1 ] ,
comment: "classic user with plain password"}
Manage your own quotas:
clickhouse_quotas_custom:
- { name: "my_custom_quota", intervals: "{{ clickhouse_quotas_intervals_default }}", comment: "Default quota - count only" }
Create any databases. By default, the state is "present".
clickhouse_dbs_custom:
- { name: testu1 }
- { name: testu2, state: present }
- { name: testu3, state: absent }
Create dictionaries via ODBC:
clickhouse_dicts:
test1:
name: test_dict
odbc_source:
connection_string: "DSN=testdb"
source_table: "dict_source"
lifetime:
min: 300
max: 360
layout: hashed
structure:
key: "testIntKey"
attributes:
- { name: testAttrName, type: UInt32, null_value: 0 }
Flag to remove ClickHouse from the host (disabled by default):
clickhouse_remove: no
Manage Kafka configuration:
clickhouse_kafka_config:
auto_offset_reset: smallest
debug: cgrp
Manage LDAP server configuration:
clickhouse_ldap_servers:
example_ldap_server:
host: "ldaps.example.com"
port: "636"
bind_dn: "EXAMPLENET\\{user_name}"
verification_cooldown: "300"
enable_tls: "yes"
tls_require_cert: "demand"
Manage Merge Tree settings:
clickhouse_merge_tree_config:
max_suspicious_broken_parts: 5
parts_to_throw_insert: 600
Example Playbook
Here’s an example of how to use this role:
- hosts: clickhouse_cluster
remote_user: root
vars:
clickhouse_users_custom:
- { name: "testuser", password_sha256_hex: "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2", ... }
clickhouse_query_log_ttl: 'event_date + INTERVAL 7 DAY DELETE'
clickhouse_dbs_custom:
- { name: testu1 }
- { name: testu2, state: present }
- { name: testu3, state: absent }
roles:
- ansible-clickhouse
To generate macros in the file host_vars\db_host_1.yml:
clickhouse_macros:
layer: 01
shard: "your_shard_name"
replica: "db_host_1"
License
BSD
Author Information
Created by ClickHouse, Inc. and role by AlexeySetevoi.
Thank you to all contributors!
Role for installation and managing ClickHouse
ansible-galaxy install AlexeySetevoi.clickhouse