community.clickhouse.clickhouse_quota module – Creates or removes a ClickHouse quota

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_quota.

New in community.clickhouse 1.1.0

Synopsis

  • Creates or removes a ClickHouse quota.

Requirements

The below requirements are needed on the host that executes this module.

  • clickhouse-driver

Parameters

Parameter

Comments

apply_to

list / elements=string

Apply this quota to the following list of users/roles dependent on apply_to_mode.

Can include special keywords of default and current_user or the name of an actual user or role.

Is an error to specify this if apply_to_mode=all.

apply_to_mode

string

When listed_only (default), the quota will only apply to the users/roles specified in apply_to.

When all, the quota will only apply to all users/roles.

When all_except_listed, the quota will only apply to all the users/roles except those specified in apply_to.

Choices:

  • "listed_only" ← (default)

  • "all"

  • "all_except_listed"

client_kwargs

dictionary

Any additional keyword arguments you want to pass to the Client interface when instantiating its object.

Default: {}

cluster

string

Run the command on all cluster hosts.

If the cluster is not configured, the command will crash with an error.

keyed_by

string

Keys the quota by the specified key (default is to not key).

Choices:

  • "user_name"

  • "ip_address"

  • "client_key"

  • "client_key,user_name"

  • "client_key,ip_address"

limits

list / elements=dictionary

The limits that this quota should enforce.

interval

string / required

The interval to apply the following quotas on.

This is in the format <number> <unit>.

Where unit is one of second, minute, hour, day, week, month, quarter or year.

max

dictionary

Maximum values to apply to this interval in this quota.

At least one key must be specified.

Mutually exclusive with limits.no_limits and limits.tracking_only.

errors

integer

Maximum number of errors to enforce in this interval.

execution_time

float

Maximum number of execution time to enforce in this interval.

failed_sequential_authentications

integer

Maximum number of failed sequential authentications to enforce in this interval.

queries

integer

Maximum number of queries to enforce in this interval.

query_inserts

integer

Maximum number of query inserts to enforce in this interval.

query_selects

integer

Maximum number of query selects to enforce in this interval.

read_bytes

integer

Maximum number of bytes read to enforce in this interval.

read_rows

integer

Maximum number of rows read to enforce in this interval.

result_bytes

integer

Maximum number of result bytes to enforce in this interval.

result_rows

integer

Maximum number of result rows to enforce in this interval.

written_bytes

integer

Maximum number of bytes written to enforce in this interval.

no_limits

boolean

Don’t apply any limits.

Mutually exclusive with limits.max and limits.tracking_only.

Choices:

  • false

  • true

randomized_start

boolean

Whether this interval’s start should be randomized.

Intervals always start at the same time if not randomized.

Choices:

  • false ← (default)

  • true

tracking_only

boolean

Just track usage instead of enforcing.

Mutually exclusive with limits.max and limits.no_limits.

Choices:

  • false

  • true

login_db

string

The same as the Client(database='...') argument.

If not passed, relies on the driver’s default argument value.

login_host

string

The same as the Client(host='...') argument.

Default: "localhost"

login_password

string

The same as the Client(password='...') argument.

If not passed, relies on the driver’s default argument value.

login_port

integer

The same as the Client(port='...') argument.

If not passed, relies on the driver’s default argument value.

login_user

string

The same as the Client(user='...') argument.

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.

name

string / required

Quota name to add or remove.

state

string

Quota state.

present creates the quota if it does not exist.

absent deletes the quota if it exists.

Choices:

  • "present" ← (default)

  • "absent"

Attributes

Attribute

Support

Description

check_mode

Support: full

Supports check_mode.

Notes

Note

  • See the clickhouse-driver documentation for more information about the driver interface.

Examples

- name: Create quota
  community.clickhouse.clickhouse_quota:
    name: test_quota
    state: present

- name: Create a quota with limits
  community.clickhouse.clickhouse_quota:
    name: test_quota
    state: present
    limits:
      - interval: 5 minute
        max:
          queries: 100
          execution_time: 100
        apply_to:
          - one_role
          - another_role
    cluster: test_cluster

- name: Remove quota
  community.clickhouse.clickhouse_quota:
    name: test_quota
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

executed_statements

list / elements=string

Data-modifying executed statements.

Returned: on success

Sample: ["CREATE QUOTA test_quota"]

Authors

  • John Garland (@johnnyg)