community.clickhouse.clickhouse_db module – Creates or removes a ClickHouse database using the clickhouse-driver Client interface
Note
This module is part of the community.clickhouse collection (version 2.0.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.clickhouse.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.clickhouse.clickhouse_db.
New in community.clickhouse 0.3.0
Synopsis
Creates or removes a ClickHouse database using the clickhouse-driver Client interface.
Requirements
The below requirements are needed on the host that executes this module.
clickhouse-driver
Parameters
Parameter |
Comments |
|---|---|
Any additional keyword arguments you want to pass to the Client interface when instantiating its object. Default: |
|
Run the command on all cluster hosts. If the cluster is not configured, the command will crash with an error. |
|
Database comment. Once set, cannot be changed. |
|
Database engine. Once set, cannot be changed. |
|
The same as the If not passed, relies on the driver’s default argument value. |
|
The same as the Default: |
|
The same as the If not passed, relies on the driver’s default argument value. |
|
The same as the If not passed, relies on the driver’s default argument value. |
|
The same as the If not passed, relies on the driver’s default argument value. Be sure your the user has permissions to read the system tables listed in the RETURN section. |
|
Database name to add or remove. |
|
Database state. If If If Choices:
|
|
Name for renaming the database. |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Supports check_mode. |
Notes
Note
See the clickhouse-driver documentation for more information about the driver interface.
Examples
- 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 DB
- name: Drop database
community.clickhouse.clickhouse_db:
login_host: localhost
login_user: alice
login_db: foo
login_password: my_password
name: test_db
state: absent
# 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Data-modifying executed statements. Returned: on success Sample: |