community.clickhouse.clickhouse_grants module – Manage grants for ClickHouse users and roles
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_grants.
New in community.clickhouse 0.9.0
Synopsis
Grants, updates, or revokes privileges for ClickHouse users and roles.
This module uses 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 grant/revoke commands on all cluster hosts. If the cluster is not configured, the command will fail with an error. |
|
If set to If set to Choices:
|
|
A user or a role to grant, update, or revoke privileges for. |
|
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. |
|
Privileges to grant. This option is required when It’s a list of dictionaries, where each dictionary specifies a set of privileges on a database object. |
|
A boolean that applies to all privileges in this set. If specified, it overrides any individual grant option settings within Choices:
|
|
The database object to grant privileges on. Use |
|
A dictionary of privileges. Keys are privilege names, like Values are booleans indicating whether to grant the privilege with the Alternatively, you can use the |
|
If If Choices:
|
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: Grant global privileges to a user
community.clickhouse.clickhouse_grants:
grantee: alice
privileges:
- object: '*.*'
privs:
"ALTER USER": true # With grant option
"CREATE DATABASE": false # Without grant option
"CREATE USER": false # Without grant option
- name: Grant privileges on a specific database
community.clickhouse.clickhouse_grants:
grantee: bob
privileges:
- object: 'infra.*'
privs:
"SELECT": true # With grant option
"INSERT": false # Without grant option
- name: Grant privileges on a cluster
community.clickhouse.clickhouse_grants:
grantee: bob
cluster: test_cluster
privileges:
- object: 'infra.*'
privs:
"SELECT": true # With grant option
"INSERT": false # Without grant option
- name: Grant SELECT on specific columns of a table
community.clickhouse.clickhouse_grants:
grantee: carol
privileges:
- object: 'sales.customers'
privs:
"SELECT(name, email)": false # Without grant option
- name: Replace all existing privileges for a user
community.clickhouse.clickhouse_grants:
grantee: david
exclusive: true
privileges:
- object: 'bar.*'
privs:
"SELECT": false # Without grant option
- name: Revoke all privileges from a user
community.clickhouse.clickhouse_grants:
grantee: eve
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Differences between the previous and current state. Only returned when diff mode is enabled (with Returned: when diff mode is enabled or check_mode is true |
|
Grants after the change. Returned: always Sample: |
|
Grants before the change. Returned: always Sample: |
|
Data-modifying executed statements. Returned: on success Sample: |