Skip to content

mysql_role: new module #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
Aug 10, 2021
Merged

Conversation

Andersson007
Copy link
Collaborator

@Andersson007 Andersson007 commented Jun 24, 2021

SUMMARY

Fixes #50

mysql_role: new module

Not sure if I'm able to finish this (I'll put it explicitly if not). Hope it'll help anyway (i.e. to define an interface, etc.)

IMPORTANT

  • I moved most of the code from the mysql_user module to the user library.
  • in the user_mod function I added a couple of conditions related to roles, look for the role variable to find those places.
  • I added a lot of maria_role across plugins/module_utils/user.py (review it carefully).
  • the module uses the user_mode function and it always reports changed=True when append_privs=yes. I wonder if it's expected behavior for the mysql_user module? (UPDATE: yes, this is the same there, checked, I'll create an issue to fix the bug alter this gets merged to avoid conflicts)
  • in a several moths after this released, we can move the Role class to a library and use in the mysql_user module to add a user to roles via a new option (called, say, roles:).
  • integration tests were added and they cover (I hope) everything available on MySQL
  • as we don't have MariaDB in our CI, i tested things manually locally on MariaDB. So if anyone tests it and confirms that everything is fine (or not), it would be great.
  • I covered a couple of classes and functions with unit tests as well. As i spent more than a week to write this, i have no wish to cover the rest at least now. As the things are covered with integration tests, it's not crucial
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

mysql_role

@codecov
Copy link

codecov bot commented Jun 24, 2021

Codecov Report

Merging #189 (d0c0f09) into main (adb201a) will increase coverage by 0.58%.
The diff coverage is 82.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #189      +/-   ##
==========================================
+ Coverage   76.92%   77.51%   +0.58%     
==========================================
  Files          20       24       +4     
  Lines        1794     2161     +367     
  Branches      439      508      +69     
==========================================
+ Hits         1380     1675     +295     
- Misses        268      319      +51     
- Partials      146      167      +21     
Impacted Files Coverage Δ
plugins/modules/mysql_role.py 80.39% <80.39%> (ø)
plugins/module_utils/user.py 81.46% <81.46%> (ø)
plugins/module_utils/implementations/mysql/role.py 100.00% <100.00%> (ø)
plugins/modules/mysql_user.py 79.38% <100.00%> (-3.21%) ⬇️
tests/unit/plugins/module_utils/test_mysql_user.py 100.00% <100.00%> (ø)
tests/unit/plugins/modules/test_mysql_role.py 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update adb201a...d0c0f09. Read the comment docs.

@Andersson007 Andersson007 changed the title [DRAFT] mysql_role: new module mysql_role: new module Jul 9, 2021
@Andersson007
Copy link
Collaborator Author

Ready for review (I updated the description, there are important information, please take a look at it first)

@Andersson007
Copy link
Collaborator Author

I updated README. Hey, folks, Friday is a good day for reviewing

@Andersson007
Copy link
Collaborator Author

I hope we'll get more reviews here. I'm gonna merge this anyway in a week or two and release a prerelease so that this won't be included in Ansible package but interested users will be able to download it via ansible-galaxy easily and test.

@Andersson007 Andersson007 reopened this Aug 9, 2021
@Andersson007 Andersson007 merged commit ce2b269 into ansible-collections:main Aug 10, 2021
Andersson007 added a commit to Andersson007/community.mysql that referenced this pull request Aug 11, 2021
* mysql_role: new module

* fixes

* fixes

* Add the role class

* Check if role exists

* role.add()

* role.__get_members

* tmp

* tmp

* Change tests

* Fix

* Fix

* add_members()

* get_privs()

* tmp

* __extract_grants() filler version

* Before big work

* tmp

* drop()

* tmp

* tmp

* Big changes

* Fix

* append_members, detach_members, append_privs

* tmp

* admin option

* Add tests

* Add tests

* Fix tests

* Remove debug warning

* Fix tests

* Add documentation

* Fix MariaDB case

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix

* Fix

* Remove debug warning

* Add try-except block

* tmp

* tmp

* tmp

* Fix

* Add err handling

* Add user check

* Check admin in db

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Fix

* Add mutually exclusive options

* Small refactoring, documenting

* Documenting, refactoring

* Change docs

* Refactoring

* Refactoring

* Refactoring

* Add unit tests

* Update README.md

(cherry picked from commit ce2b269)
Andersson007 added a commit that referenced this pull request Aug 11, 2021
* mysql_role: new module

* fixes

* fixes

* Add the role class

* Check if role exists

* role.add()

* role.__get_members

* tmp

* tmp

* Change tests

* Fix

* Fix

* add_members()

* get_privs()

* tmp

* __extract_grants() filler version

* Before big work

* tmp

* drop()

* tmp

* tmp

* Big changes

* Fix

* append_members, detach_members, append_privs

* tmp

* admin option

* Add tests

* Add tests

* Fix tests

* Remove debug warning

* Fix tests

* Add documentation

* Fix MariaDB case

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix MariaDB

* Fix

* Fix

* Remove debug warning

* Add try-except block

* tmp

* tmp

* tmp

* Fix

* Add err handling

* Add user check

* Check admin in db

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Fix

* Add mutually exclusive options

* Small refactoring, documenting

* Documenting, refactoring

* Change docs

* Refactoring

* Refactoring

* Refactoring

* Add unit tests

* Update README.md

(cherry picked from commit ce2b269)
@Andersson007
Copy link
Collaborator Author

community.mysql 2.2.0-a1 has been released and available to install via galaxy or directly from https://galaxy.ansible.com/community/mysql. It contains the mysql_role new module. Pay attention that this is a pre-release and is not considered ready for production.
Any feedback would be much appreciated.
After confirming that everything is find with the module (and with mysql_user module as well because both the modules share some code), we can release 2.2.0.

laurent-indermuehle added a commit to laurent-indermuehle/community.mysql that referenced this pull request Oct 11, 2023
This was introduced in ansible-collections#189. To my knowledge, there is no difference
between MySQL and MariaDB regarding roles or when you call a user by
its name alone. Both works if the host it '%'. Same for roles.
laurent-indermuehle added a commit to laurent-indermuehle/community.mysql that referenced this pull request Oct 11, 2023
This was introduced in ansible-collections#189. To my knowledge, there is no difference
between MySQL and MariaDB regarding roles or when you call a user by
its name alone. Both works if the host it '%'. Same for roles.
laurent-indermuehle added a commit to laurent-indermuehle/community.mysql that referenced this pull request Oct 11, 2023
This was introduced in ansible-collections#189. To my knowledge, there is no difference
between MySQL and MariaDB regarding roles or when you call a user by
its name alone. Both works if the host it '%'. Same for roles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create ROLES, assign them and SET default role
2 participants