clickhouse_db
Create, update, rename or drop a ClickHouse database
Collection: community.clickhouse
Full Name: community.clickhouse.clickhouse_db
Synopsis
Create, update, rename or drop a ClickHouse database
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| login_host | str | localhost | ClickHouse host | |
| login_port | int | Native protocol port | ||
| login_db | str | Database used to establish the connection | ||
| login_user | str | ClickHouse user | ||
| login_password | str | ClickHouse password; output is private | ||
| client_kwargs | dict | map[] | Additional native client options | |
| success_on | list | [497] | Server error codes treated as unchanged success | |
| state | str | present | present, absent or rename | |
| name | str | yes | Database name | |
| engine | str | Database engine used on create | ||
| cluster | str | Cluster for DDL statements | ||
| target | str | Destination name when state is rename | ||
| comment | str | Database comment; update requires ClickHouse25.8 or newer |
Example
yaml
- name: Create database
community.clickhouse.clickhouse_db:
login_host: localhost
login_user: alice
login_db: foo
login_password: my_password
name: test_db
engine: Memory
state: present
comment: Test DByaml
- name: Drop database
community.clickhouse.clickhouse_db:
login_host: localhost
login_user: alice
login_db: foo
login_password: my_password
name: test_db
state: absentyaml
# Rename the database test_db to prod_db.
# If the database test_db exists, it will be renamed to prod_db.
# If the database test_db does not exist and the prod_db database exists,
# the module will report that nothing has changed.
# If both the databases exist, an error will be raised.
- name: Rename database
community.clickhouse.clickhouse_db:
login_host: localhost
login_user: alice
login_db: foo
login_password: my_password
name: test_db
target: prod_db
cluster: test_cluster
state: rename