Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit b2a0d2c

Browse files
Merge pull request #16 from krzyzakp/master
Fixing travis/runtime errors. Adding few more config to management thanks to @krzyzakp
2 parents 2701eb7 + 637eaee commit b2a0d2c

14 files changed

+118
-38
lines changed

.travis.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ matrix:
2828
dist: xenial
2929
sudo: true
3030
env: ANSIBLE_VERSION='latest'
31-
- os: linux
32-
dist: precise
33-
sudo: true
34-
env: ANSIBLE_VERSION='ansible>=2.4,<2.5'
35-
- os: linux
36-
dist: precise
37-
sudo: true
38-
env: ANSIBLE_VERSION='ansible>=2.3,<2.4'
39-
- os: linux
40-
dist: precise
41-
sudo: true
42-
env: ANSIBLE_VERSION='latest'
4331

4432
# Use the new container infrastructure
4533
sudo: true
@@ -94,4 +82,4 @@ script:
9482

9583

9684
notifications:
97-
webhooks: https://galaxy.ansible.com/api/v1/notifications/
85+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ clickhouse_config:
7979

8080
clickhouse_dicts: []
8181

82+
clickhouse_path_user_files: /var/lib/clickhouse/user_files/

meta/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ galaxy_info:
1111
versions:
1212
- xenial
1313
- trusty
14-
- precise
14+
- name: Debian
15+
versions:
16+
- jessie
17+
- stretch
1518

1619
galaxy_tags:
1720
- clickhouse

tasks/config_db.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Gather list of existing databases
3-
command: "clickhouse-client -h localhost -q 'show databases'"
3+
command: "clickhouse-client -h 127.0.0.1 -q 'show databases'"
44
changed_when: False
55
register: existing_databases
66
tags: [config_db]
@@ -12,7 +12,7 @@
1212
tags: [config_db]
1313

1414
- name: Config | Create database config
15-
command: "clickhouse-client -h localhost -q 'CREATE DATABASE IF NOT EXISTS `{{ item.name }}`'"
15+
command: "clickhouse-client -h 127.0.0.1 -q 'CREATE DATABASE IF NOT EXISTS `{{ item.name }}`'"
1616
with_items: "{{ clickhouse_dbs }}"
1717
when: (item.state is undefined or item.state == 'present') and item.name not in existing_databases.stdout_lines
1818
tags: [config_db]

tasks/config_sys.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,52 @@
1414

1515
- name: Config | Generate system config
1616
template:
17-
src: config.j2
18-
dest: "{{ clickhouse_path_configdir }}/config.xml"
19-
owner: clickhouse
20-
group: clickhouse
17+
src: config.j2
18+
dest: "{{ clickhouse_path_configdir }}/config.xml"
19+
owner: clickhouse
20+
group: clickhouse
2121
notify: restart-ch
2222
become: true
2323

2424
- name: Config | Generate users config
2525
template:
26-
src: users.j2
27-
dest: "{{ clickhouse_path_configdir }}/users.xml"
28-
owner: clickhouse
29-
group: clickhouse
26+
src: users.j2
27+
dest: "{{ clickhouse_path_configdir }}/users.xml"
28+
owner: clickhouse
29+
group: clickhouse
3030
notify: restart-ch
3131
become: true
3232

33-
- meta: flush_handlers
33+
- name: Config | Generate remote_servers config
34+
template:
35+
src: remote_servers.j2
36+
dest: "{{ clickhouse_path_configdir }}/conf.d/clickhouse_remote_servers.xml"
37+
owner: clickhouse
38+
group: clickhouse
39+
notify: restart-ch
40+
become: true
41+
when: clickhouse_shards is defined
3442

43+
- name: Config | Generate macros config
44+
template:
45+
src: macros.j2
46+
dest: "{{ clickhouse_path_configdir }}/conf.d/macros.xml"
47+
owner: clickhouse
48+
group: clickhouse
49+
mode: 0644
50+
notify: restart-ch
51+
become: true
52+
when: clickhouse_macros is defined
3553

54+
- name: Config | Generate zookeeper servers config
55+
template:
56+
src: zookeeper-servers.j2
57+
dest: "{{ clickhouse_path_configdir }}/conf.d/zookeeper-servers.xml"
58+
owner: clickhouse
59+
group: clickhouse
60+
mode: 0644
61+
notify: restart-ch
62+
become: true
63+
when: clickhouse_zookeeper_nodes is defined
3664

65+
- meta: flush_handlers

tasks/precheck.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
ignore_errors: yes
1616
when: ansible_pkg_mgr == 'apt' and clickhouse_setup == 'package'
1717
changed_when: False
18+
check_mode: no

templates/config.j2

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0"?>
2+
<!-- {{ ansible_managed }} -->
23
<yandex>
34
<logger>
45
<level>{{ clickhouse_logger.level }}</level>
@@ -58,12 +59,14 @@
5859
<!--
5960
<interserver_http_host>example.yandex.ru</interserver_http_host>
6061
-->
61-
62+
{% if clickhouse_interserver_http_host is defined %}
63+
<interserver_http_host>{{ clickhouse_interserver_http_host }}</interserver_http_host>
64+
{% endif %}
6265
<!-- Listen specified host. use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere. -->
6366
<!-- <listen_host>::</listen_host> -->
64-
{% for host in clickhouse_listen_host %}
67+
{% for host in clickhouse_listen_host %}
6568
<listen_host>{{ host }}</listen_host>
66-
{% endfor %}
69+
{% endfor %}
6770

6871
<max_connections>{{ clickhouse_config.max_connections }}</max_connections>
6972
<keep_alive_timeout>{{ clickhouse_config.keep_alive_timeout }}</keep_alive_timeout>
@@ -94,7 +97,8 @@
9497

9598
<!-- Path to temporary data for processing hard queries. -->
9699
<tmp_path>{{ clickhouse_path_tmp }}</tmp_path>
97-
100+
101+
<user_files_path>{{ clickhouse_path_user_files }}</user_files_path>
98102
<!-- Path to configuration file with users, access rights, profiles of settings, quotas. -->
99103
<users_config>users.xml</users_config>
100104

@@ -201,7 +205,7 @@
201205
-->
202206
<database>system</database>
203207
<table>query_log</table>
204-
208+
<partition_by>toYYYYMM(event_date)</partition_by>
205209
<!-- Interval of flushing data. -->
206210
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
207211
</query_log>
@@ -307,4 +311,7 @@
307311
</retention>
308312
</default>
309313
</graphite_rollup_example>
314+
315+
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path>
316+
310317
</yandex>

templates/macros.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<!-- {{ ansible_managed }} -->
3+
<yandex>
4+
<macros>
5+
{% for key, value in clickhouse_macros.items() %}
6+
<{{ key }}>{{ value }}</{{ key }}>
7+
{% endfor %}
8+
</macros>
9+
</yandex>

templates/remote_servers.j2

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<!-- {{ ansible_managed }} -->
3+
<yandex>
4+
<remote_servers>
5+
{% for shard_name, replicas in clickhouse_shards.iteritems() %}
6+
<{{ shard_name }}>
7+
<shard>
8+
<internal_replication>true</internal_replication>
9+
{% for replica in replicas %}
10+
<replica>
11+
<host>{{ replica['host'] }}</host>
12+
<port>{{ replica['port'] | default(9000) }}</port>
13+
</replica>
14+
{% endfor %}
15+
</shard>
16+
</{{ shard_name }}>
17+
{% endfor %}
18+
</remote_servers>
19+
</yandex>

templates/zookeeper-servers.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!-- {{ ansible_managed }} -->
3+
<yandex>
4+
<zookeeper>
5+
{% for server in clickhouse_zookeeper_nodes %}
6+
<node>
7+
{% for key, value in server.items() %}
8+
<{{ key }}>{{ value }}</{{ key }}>
9+
{% endfor %}
10+
</node>
11+
{% endfor %}
12+
</zookeeper>
13+
</yandex>
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
clickhouse_supported: yes
22
clickhouse_repo: "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/"
3-
clickhouse_repo_old: "deb http://repo.yandex.ru/clickhouse/xenial stable main"
43
clickhouse_repo_keyserver: keyserver.ubuntu.com
54
clickhouse_repo_key: E0C56BD4
65
clickhouse_package:
76
- clickhouse-client
8-
- clickhouse-server-base
9-
- clickhouse-server-common
7+
- clickhouse-common-static
8+
- clickhouse-server
109
clickhouse_path_configdir: "/etc/clickhouse-server"
1110
clickhouse_path_logdir: "/var/log/clickhouse-server"
1211
clickhouse_path_data: "/var/lib/clickhouse/"
1312
clickhouse_path_tmp: "/var/lib/clickhouse/tmp/"
14-

vars/Debian_stretch.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
clickhouse_supported: yes
2+
clickhouse_repo: "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/"
3+
clickhouse_repo_keyserver: keyserver.ubuntu.com
4+
clickhouse_repo_key: E0C56BD4
5+
clickhouse_package:
6+
- clickhouse-client
7+
- clickhouse-common-static
8+
- clickhouse-server
9+
clickhouse_path_configdir: "/etc/clickhouse-server"
10+
clickhouse_path_logdir: "/var/log/clickhouse-server"
11+
clickhouse_path_data: "/var/lib/clickhouse/"
12+
clickhouse_path_tmp: "/var/lib/clickhouse/tmp/"

vars/Ubuntu_trusty.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ clickhouse_repo_keyserver: keyserver.ubuntu.com
55
clickhouse_repo_key: E0C56BD4
66
clickhouse_package:
77
- clickhouse-client
8-
- clickhouse-server-base
9-
- clickhouse-server-common
8+
- clickhouse-common-static
9+
- clickhouse-server
1010
clickhouse_path_configdir: "/etc/clickhouse-server"
1111
clickhouse_path_logdir: "/var/log/clickhouse-server"
1212
clickhouse_path_data: "/var/lib/clickhouse/"

vars/Ubuntu_xenial.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ clickhouse_repo_keyserver: keyserver.ubuntu.com
55
clickhouse_repo_key: E0C56BD4
66
clickhouse_package:
77
- clickhouse-client
8-
- clickhouse-server-base
9-
- clickhouse-server-common
8+
- clickhouse-common-static
9+
- clickhouse-server
1010
clickhouse_path_configdir: "/etc/clickhouse-server"
1111
clickhouse_path_logdir: "/var/log/clickhouse-server"
1212
clickhouse_path_data: "/var/lib/clickhouse/"

0 commit comments

Comments
 (0)