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

Commit 74341eb

Browse files
Merge pull request #52 from sportsru/db_cluster_and_engine
Expansion of the functionality of creating and deleting databases
2 parents 7331c80 + 258aa5a commit 74341eb

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ clickhouse_dbs_custom:
101101
- { name: testu2 }
102102
- { name: testu3 }
103103
- { name: testu4, state: absent }
104-
- { name: testu4, state: present }
104+
- { name: testu5, state: present }
105+
- { name: testu6, state: absent, cluster: testu6 }
106+
- { name: testu7, state: present, cluster: testu7 }
107+
- { name: testu8, state: absent, cluster: testu8, engine: Lazy(3600) }
108+
- { name: testu9, state: present, cluster: testu9, engine: Lazy(3600) }
109+
105110
```
106111

107112
F: You can create dictionary via odbc

tasks/config_db.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
tags: [config_db]
77

88
- name: Config | Delete database config
9-
command: "clickhouse-client -h 127.0.0.1 --port {{ clickhouse_tcp_port }} -q 'DROP DATABASE IF EXISTS `{{ item.name }}`'"
9+
command: |
10+
clickhouse-client -h 127.0.0.1 --port {{ clickhouse_tcp_port }}
11+
-q 'DROP DATABASE IF EXISTS `{{ item.name }}`
12+
{% if item.cluster is defined %}ON CLUSTER `{{ item.cluster }}`{% endif %}'
1013
with_items: "{{ clickhouse_dbs }}"
1114
when: item.state is defined and item.state == 'absent' and item.name in existing_databases.stdout_lines
1215
tags: [config_db]
1316

1417
- name: Config | Create database config
15-
command: "clickhouse-client -h 127.0.0.1 --port {{ clickhouse_tcp_port }} -q 'CREATE DATABASE IF NOT EXISTS `{{ item.name }}`'"
18+
command: |
19+
clickhouse-client -h 127.0.0.1 --port {{ clickhouse_tcp_port }}
20+
-q 'CREATE DATABASE IF NOT EXISTS `{{ item.name }}`
21+
{% if item.cluster is defined %}ON CLUSTER `{{ item.cluster }}`{% endif %}
22+
{% if item.engine is defined %}ENGINE = {{ item.engine }}{% endif %}'
1623
with_items: "{{ clickhouse_dbs }}"
1724
when: (item.state is undefined or item.state == 'present') and item.name not in existing_databases.stdout_lines
1825
tags: [config_db]

0 commit comments

Comments
 (0)