Skip to content

Commit

Permalink
clickhouse_grants: new module
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersson007 committed Jan 28, 2025
1 parent 4bbd6c5 commit 3b98b1c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/integration/targets/clickhouse_grants/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_clickhouse
48 changes: 48 additions & 0 deletions tests/integration/targets/clickhouse_grants/tasks/initial.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################

- name: Create a test dabase
community.clickhouse.clickhouse_client:
execute: CREATE DATABASE foo

- name: Create a test table
register: result
community.clickhouse.clickhouse_client:
login_host: localhost
client_kwargs:
connect_timeout: 20
execute: >
CREATE TABLE IF NOT EXISTS foo.test_table_1
(id UInt64, x String) ENGINE = Memory
execute_kwargs:
types_check: false

- name: Insert into test table using named args
register: result
community.clickhouse.clickhouse_client:
execute: "INSERT INTO test_table_1 (x) VALUES (%(a)s), (%(b)s), (%(c)s)"
execute_kwargs:
params:
a: one
b: two
c: three

- name: Create a test user
community.clickhouse.clickhouse_user:
state: present
name: alice
password: querty

- name: Check the user exists
register: result
community.clickhouse.clickhouse_info:
login_host: localhost
client_kwargs:
connect_timeout: 20

- name: Check user's attributes
ansible.builtin.assert:
that:
- result["users"]["alice"] != {}
7 changes: 7 additions & 0 deletions tests/integration/targets/clickhouse_grants/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################

# Initial CI tests of clickhouse_grants module
- import_tasks: initial.yml

0 comments on commit 3b98b1c

Please sign in to comment.