Skip to content

Commit

Permalink
Fail when grantee does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersson007 committed Feb 4, 2025
1 parent 265951b commit 1767afd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/modules/clickhouse_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __populate_info(self):

if result != []:
self.grantee_exists = True
else:
self.module.fail_json(msg="Grantee %s does not exist" % self.grantee)

def get(self):
# WIP
Expand Down
15 changes: 14 additions & 1 deletion tests/integration/targets/clickhouse_grants/tasks/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,24 @@
that:
- result["users"]["alice"]["grants"] != []

- name: Grant privs to non-existent grantee, must fail
register: result
ignore_errors: true
community.clickhouse.clickhouse_grants:
state: present
grantee: notexists

- name: Check that it failed
ansible.builtin.assert:
that:
- result is failed
- result.msg is search("does not exist")

- name: Grant privs
register: result
community.clickhouse.clickhouse_grants:
state: present
grantee: bob
grantee: alice

- name: Check
ansible.builtin.assert:
Expand Down

0 comments on commit 1767afd

Please sign in to comment.