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

Commit

Permalink
Merge pull request #52 from sportsru/db_cluster_and_engine
Browse files Browse the repository at this point in the history
Expansion of the functionality of creating and deleting databases
  • Loading branch information
AlexeySetevoi authored Dec 14, 2020
2 parents 7331c80 + 258aa5a commit 74341eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ clickhouse_dbs_custom:
- { name: testu2 }
- { name: testu3 }
- { name: testu4, state: absent }
- { name: testu4, state: present }
- { name: testu5, state: present }
- { name: testu6, state: absent, cluster: testu6 }
- { name: testu7, state: present, cluster: testu7 }
- { name: testu8, state: absent, cluster: testu8, engine: Lazy(3600) }
- { name: testu9, state: present, cluster: testu9, engine: Lazy(3600) }

```

F: You can create dictionary via odbc
Expand Down
11 changes: 9 additions & 2 deletions tasks/config_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
tags: [config_db]

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

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

0 comments on commit 74341eb

Please sign in to comment.