community.clickhouse.clickhouse_role module – Creates or removes a ClickHouse role.

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

New in community.clickhouse 0.5.0

Synopsis

  • Creates or removes a ClickHouse role.

Requirements

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

  • clickhouse-driver

Parameters

Parameter

Comments

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.

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

Role name to add or remove.

settings

list / elements=string

Settings with their limitations that apply to the role.

You can also specify the profile from which the settings will be inherited.

state

string

Role state.

present creates the role if it does not exist.

absent deletes the role 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 role
  community.clickhouse.clickhouse_role:
    name: test_role
    state: present

- name: Create a role with settings
  community.clickhouse.clickhouse_role:
    name: test_role
    state: present
    settings:
      - max_memory_usage = 15000 MIN 15000 MAX 16000 READONLY
      - PROFILE restricted
    cluster: test_cluster

- name: Remove role
  community.clickhouse.clickhouse_role:
    name: test_role
    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 ROLE test_role"]

Authors

  • Don Naro (@oranod)

  • Aleksandr Vagachev (@aleksvagachev)

  • Andrew Klychkov (@Andersson007)