PARALLAX

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

NameTypeRequiredDefaultDescription
login_hoststrlocalhostClickHouse host
login_portintNative protocol port
login_dbstrDatabase used to establish the connection
login_userstrClickHouse user
login_passwordstrClickHouse password; output is private
client_kwargsdictmap[]Additional native client options
success_onlist[497]Server error codes treated as unchanged success
statestrpresentpresent, absent or rename
namestryesDatabase name
enginestrDatabase engine used on create
clusterstrCluster for DDL statements
targetstrDestination name when state is rename
commentstrDatabase 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 DB
yaml
- 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
yaml
# 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
Search
    ↑ ↓ move↵ openesc close