Skip to content
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

Add TLS connection parameters #369

Conversation

Jorge-Rodriguez
Copy link

SUMMARY

Add support for TLS REQUIRES options, to enforce TLS client connections for users.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

mysql_user

ADDITIONAL INFORMATION

This is a PoC pull request on how these parameters could be handled.
IMPORTANT!! THIS HAS NOT BEEN TESTED

@ansibullbot ansibullbot added affects_2.10 feature This issue/PR relates to a feature request module module labels May 19, 2020
@Jorge-Rodriguez
Copy link
Author

Ping @Andersson007 @rwky @jpmens

@pabelanger
Copy link

recheck

@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test ignores [explain] failed with 2 errors:

tests/sanity/ignore-2.10.txt:1942:1: File 'tests/unit/plugins/module_utils/gcp/test_gcp_utils.py' does not exist
tests/sanity/ignore-2.10.txt:1943:1: File 'tests/unit/plugins/module_utils/gcp/test_gcp_utils.py' does not exist

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/database/mysql/mysql_user.py:384:97: E231: missing whitespace after ','

click here for bot help

@felixfontein
Copy link
Collaborator

Hmm, the --test ignores errors are caused by me, fixing them in #370.

Copy link
Contributor

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jorge-Rodriguez thanks for the PR!
Could you please add integration tests? See existing ones in tests/integration/targes/mysq_user.
(Maybe there is an old version of mysql installed)

changelogs/fragments/369-mysql_user_add_tls_requires Outdated Show resolved Hide resolved
plugins/modules/database/mysql/mysql_user.py Outdated Show resolved Hide resolved
@Andersson007
Copy link
Contributor

if this is a MariaDB feature, there are also tests for mariadb 10+. Look for directories in tests/integration/targets that contain mariadb in their names

@Andersson007
Copy link
Contributor

I kicked the tests here as well. Please, fix sanity related stuff (there is a guid in the ansible documentation how to run sanity tests locally using docker containers. Helps to catch such errors before pushing)

@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test pylint [explain] failed with 1 error:

plugins/modules/database/mysql/mysql_user.py:384:96: bad-whitespace: Exactly one space required after comma     return "REQUIRE %s" % ' AND '.join([' '.join(filter(None, (key, fix_quotes(value)))) for key,value in tls_requires.items()])                                                                                                 ^

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

plugins/modules/database/mysql/mysql_user.py:384:97: E231: missing whitespace after ','

click here for bot help

@Jorge-Rodriguez
Copy link
Author

It is not a MariaDB feature. I found the documentation on the mariadb link but the tls options are part of mysql. Maybe I can find the documentation on mysql.

@Andersson007
Copy link
Contributor

any updates on this?

@Jorge-Rodriguez
Copy link
Author

I'm still working on it, but the last couple of days have been quite busy at work so I didn't manage to get any code in. I have not abandoned this.

@gundalow
Copy link
Contributor

gundalow commented Jun 8, 2020

recheck

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Jun 8, 2020
@Jorge-Rodriguez
Copy link
Author

Jorge-Rodriguez commented Jun 10, 2020

Attending #AnsibleAutomates2020, will get on with this afterwards.

@ansibullbot ansibullbot added integration tests/integration and removed stale_ci CI is older than 7 days, rerun before merging labels Jun 11, 2020
@Jorge-Rodriguez
Copy link
Author

@Andersson007 does this look ok, or should I squash into a single commit?

@Andersson007
Copy link
Contributor

@Jorge-Rodriguez it's ok as it is, no actions needed. I'm on a public holiday today. I'll try to make time to look at the pr tomorrow. Or maybe today later. Thanks for doing this!

Comment on lines +3 to +4
deprecated_features:
- mysql_user - using ``REQUIRESSL`` in ``priv`` is deprecated in favor of ``tls_requires`` (https://github.com/ansible-collections/community.general/pull/369).
Copy link
Contributor

@Andersson007 Andersson007 Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
deprecated_features:
- mysql_user - using ``REQUIRESSL`` in ``priv`` is deprecated in favor of ``tls_requires`` (https://github.com/ansible-collections/community.general/pull/369).
deprecated_features:
- mysql_user - using ``REQUIRESSL`` in ``priv`` is deprecated in favor of ``tls_requires`` (https://github.com/ansible-collections/community.general/pull/369).

is it necessary to deprecate this feature? I'd avoid deprecations (if possible).
Can we make priv: REQUIRESSL and tls_requires mutually exclusive?
I don't insist, it's just topic to discuss

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just reordered the code, now TLS requires are handled after privileges so if both priv:REQUIRESSL and tls_requires are specified, tls_requires takes precedence.
It's not really query optimal as it means that first we'd set REQUIRE SSL and modify it immediately after.
I could remove the deprecation notice and replace it with a 'try to use tls_requires instead, please' note.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good (imo).
Still waiting for @bmalynovytch 's opinion because he's a MySQL WG leader

@Andersson007
Copy link
Contributor

Andersson007 commented Jun 24, 2020

@bmalynovytch what do you think about the pr?

@Andersson007
Copy link
Contributor

we also need check_mode: yes cases in the tests and checks that everything works as expected:

  1. Try to change something which weren't changed before with check_mode: yes. It must report that result is changed
  2. Then check that it wasn't actually changed
  3. Then change it not in check_mode
  4. After that try to change it again with check_mode: yes. It must report that result is not changed

I hope you understand why this PR is being reviewed so thoroughly. These changes are significant and the module is one of the crutial for MySQL support. Thanks for your patience and being persistent.

@Jorge-Rodriguez
Copy link
Author

I have a modification check on the tests (call to user_mod) I could splice the check mode tests in there. I should probably test check mode on user_add, so I could pretend that to the current battery of tests, i.e.:

  1. Add use in check mode
  2. Assert result is changed
  3. Assert user isn't present
  4. Continue with existing test battery.

I'm more than happy to see this PR going through such a thorough review. I need to take a cooler of days off of this now, but you can expect new changes coming by the turn of July.

@felixfontein felixfontein changed the base branch from master to main July 6, 2020 07:56
@ansibullbot ansibullbot added new_contributor Help guide this first time contributor stale_ci CI is older than 7 days, rerun before merging labels Jul 6, 2020
@felixfontein
Copy link
Collaborator

CC @bmildren

@ansibullbot ansibullbot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_module New module new_plugin New plugin and removed community_review labels Jul 13, 2020
@Andersson007
Copy link
Contributor

all mysql stuff have been recently moved to https://github.com/ansible-collections/community.mysql by @bmildren
feel free to move the PR to there

@Andersson007
Copy link
Contributor

@Jorge-Rodriguez i think there's no point to wait for anyone else. When it's moved, we could merge this.

@Jorge-Rodriguez
Copy link
Author

@Andersson007 Roger. I still have those extra tests we talked about pending. I'll add those to the moved PR

@Andersson007
Copy link
Contributor

@Jorge-Rodriguez ah, nice!

@nerijus
Copy link

nerijus commented Jul 23, 2020

PR moved to ansible-collections/community.mysql#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request integration tests/integration module module needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor new_module New module new_plugin New plugin stale_ci CI is older than 7 days, rerun before merging tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants