ansible-collections / community.clickhouse

Ansible Community ClickHouse Collection
GNU General Public License v3.0
7 stars 5 forks source link

clickhouse_role: create MVP for the module #48

Closed Andersson007 closed 6 months ago

Andersson007 commented 8 months ago
SUMMARY

clickhouse_role: create MVP for the module

To accomplish this, I would follow the following algorithm:

  1. Set up a dev environment using the quick start guide
  2. Add integration tests (yes, exactly now) by copying recursively the /test/integration/targets/clickhouse_db directory to /test/integration/targets/clickhouse_role
  3. Replace all the content of ./tasks/initial.yml in that directory with something like - meta: end_play for now as there's nothing to test
  4. Run the integration tests with ansible-test integration clickhouse_role --docker ubuntu2204 -vvv, they should pass
  5. Copy plugins/modules/clickhouse_db.py to plugins/modules/clickhouse_role.py
  6. For MVP, add only the following arguments to your module: state: present|absent and name: rolename. Update the DOCUMENTATION and EXAMPLES section correspondingly.
  7. You can use the code of clickhouse_db that is already in the file. Simplify it. To learn what queries you need to execute to achieve the result, see this page. Basically, it's only CREATE ROLE <rolename> (when the state is present and the role does not exist) and DROP ROLE <rolename> (when the state is absent and the role exists). To figure out whether the role exists or not query the system.roles table with SELECT 1 (or name if it doesn't work) FROM system.roles WHERE name = '<rolename>' and check the result.
  8. When it's done, run sanity tests with ansible-tests sanity plugins/modules/clickhouse_role.py --docker: it'll help you catch some code syntax errors besides sanity errors
  9. When the sanity run is OK, replace the - meta: end_play with a real test in tests/integration/targets/clickhouse_role/tasks/initial.yml with a module invocation similarly as in the same file but for clickhouse_db target.
  10. Run the tests. After they are green, submit a PR

If you got any questions along the way, just ask

Andersson007 commented 8 months ago

I think @oraNod would take a look

Andersson007 commented 8 months ago

@oraNod what did @aleksvagachev in the clickhouse_user pr is very similar to what i wrote here. FYI

oraNod commented 7 months ago

@Andersson007 Hey, sorry for the delay in replying but I'll start working on this next week and will let you know if any questions come up. Cheers!

Andersson007 commented 7 months ago

@Andersson007 Hey, sorry for the delay in replying but I'll start working on this next week and will let you know if any questions come up. Cheers!

@oraNod sure, no worries!