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 parameter to redis module #4207

Merged

Conversation

jcharlytown
Copy link
Contributor

SUMMARY

Add tls parameter to redis module

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

module redis

ADDITIONAL INFORMATION

None

@ansibullbot
Copy link
Collaborator

cc @slok
click here for bot help

@ansibullbot ansibullbot added database feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) labels Feb 16, 2022
@jcharlytown jcharlytown force-pushed the add-redis-tls-support branch from a6d1676 to dff30ef Compare February 16, 2022 12:55
@jcharlytown jcharlytown force-pushed the add-redis-tls-support branch from dff30ef to 3eb4b86 Compare February 16, 2022 12:56
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

I wonder whether it wouldn't be better to directly use the redis module_utils and docs_fragment; that would add a few more features to this module.

The main reason against that is right now that this would add another dependency (certifi) to this module. But if the module_utils is changed so that certifi is only required when tls=true, this would be ok, since so far this module didn't support TLS at all.

But if we add the tls option manually, this module will behave different from the other redis modules, and it won't be possible to adjust the behvaior (and add the dependency) without a breaking change.

So going that route would be much better.

changelogs/fragments/4207-add-redis-tls-support.yml Outdated Show resolved Hide resolved
plugins/modules/database/misc/redis.py Show resolved Hide resolved
@felixfontein felixfontein added backport-4 check-before-release PR will be looked at again shortly before release and merged if possible. labels Feb 16, 2022
@jcharlytown
Copy link
Contributor Author

@felixfontein , what you're saying is that it cannot/will not be merged in this form?

I did not follow this argument:

But if we add the tls option manually, this module will behave different from the other redis modules, and it won't be possible to adjust the behvaior (and add the dependency) without a breaking change.

The option I added is the same as for the other redis modules - except the default. Is there a way to use module_utils but overwrite the default? Otherwise this would also be a breaking change as well, correct?

@felixfontein
Copy link
Collaborator

@felixfontein , what you're saying is that it cannot/will not be merged in this form?

I didn't say that.

I did not follow this argument:

But if we add the tls option manually, this module will behave different from the other redis modules, and it won't be possible to adjust the behvaior (and add the dependency) without a breaking change.

The option I added is the same as for the other redis modules - except the default. Is there a way to use module_utils but overwrite the default? Otherwise this would also be a breaking change as well, correct?

Yes, you can modify redis_auth_argument_spec as follows:

def redis_auth_argument_spec(tls_default = True):
    ...
        tls=dict(type='bool',
                 default=tls_default),
    ...

Then you can use redis_auth_argument_spec(tls_default=False) in the module.

You should also modify fail_imports to

def fail_imports(module, needs_certifi=True):
    ...
    if not HAS_CERTIFI_PACKAGE and needs_certifi:
    ...

Then you can use fail_imports(module, needs_certifi=module.params['tls']) instead of fail_imports().

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added docs_fragments docs_fragments plugin (shared docs) module_utils module_utils labels Feb 21, 2022
@jcharlytown
Copy link
Contributor Author

@felixfontein , I upgraded the PR as outlined in your comment. I have tested both redis-data and redis modules.

However, I am confident regarding the doc fragments I have created. Is there a way to parametrize doc fragments? If not, I think other options would be to duplicate the doc fragment, either into another fragment or directly into the module. Opinions?

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 21, 2022
plugins/doc_fragments/redis.py Outdated Show resolved Hide resolved
plugins/doc_fragments/redis_tls_false.py Outdated Show resolved Hide resolved
plugins/modules/database/misc/redis.py Show resolved Hide resolved
changelogs/fragments/4207-add-redis-tls-support.yml Outdated Show resolved Hide resolved
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 22, 2022
@jcharlytown jcharlytown force-pushed the add-redis-tls-support branch from b49f15f to fbef11b Compare February 23, 2022 22:08
@jcharlytown jcharlytown force-pushed the add-redis-tls-support branch from fbef11b to e205260 Compare February 23, 2022 22:33
@ansibullbot ansibullbot added the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI label Feb 23, 2022
@ansibullbot ansibullbot removed the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI label Feb 23, 2022
@felixfontein
Copy link
Collaborator

The commit e205260 undid way too much. You need to keep the changes to the documentation in plugins/modules/database/misc/redis.py.

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Mar 4, 2022
@jcharlytown
Copy link
Contributor Author

@felixfontein , honestly, I do not know which direction you want me to take this. The doc fragment gives a conflicting default value for the TLS option. From my understand, without removing this option from the fragment, I won't be able to use it for the redis module. I see the following options:

  1. Do not use the fragment for redis module, duplicating the documentation (what is currently implemented)
  2. Remove the TLS option from the fragment, reusing the fragment for all modules, adding the TLS option explicitly to all modules
  3. Factoring out the TLS option into separate fragments, avoiding duplication (what was implemented previously - I didn't like it either though)

Out of your comments I am unable to infer what you would llike to see. Also, I am totally fine with you adding a commit yourself to rectify what ever is wrong in your opinion.

@felixfontein
Copy link
Collaborator

The correct way is: use the original fragment, and overwrite this specific value from it in the module(s) where you need a different value.

@ansibullbot ansibullbot removed the stale_ci CI is older than 7 days, rerun before merging label Mar 7, 2022
@felixfontein
Copy link
Collaborator

If nobody complains, I'll merge by the end of this week.

@felixfontein felixfontein merged commit 9a74ace into ansible-collections:main Mar 11, 2022
@patchback
Copy link

patchback bot commented Mar 11, 2022

Backport to stable-4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4/9a74ace1e47816c82f145883daa1e140cff17ee6/pr-4207

Backported as #4343

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Mar 11, 2022
patchback bot pushed a commit that referenced this pull request Mar 11, 2022
* Add tls parameter to redis module

* Rename changelog fragment to match PR

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

* Port redis module to redis auth module util

* Update changelogs/fragments/4207-add-redis-tls-support.yml

Co-authored-by: Felix Fontein <[email protected]>

* Update plugins/modules/database/misc/redis.py

Co-authored-by: Felix Fontein <[email protected]>

* Undo reuse of redis auth doc fragment

* Use doc fragment.

Co-authored-by: Julian Faude <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 9a74ace)
@felixfontein
Copy link
Collaborator

@jcharlytown thanks for your contribution!

felixfontein pushed a commit that referenced this pull request Mar 11, 2022
* Add tls parameter to redis module

* Rename changelog fragment to match PR

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

* Port redis module to redis auth module util

* Update changelogs/fragments/4207-add-redis-tls-support.yml

Co-authored-by: Felix Fontein <[email protected]>

* Update plugins/modules/database/misc/redis.py

Co-authored-by: Felix Fontein <[email protected]>

* Undo reuse of redis auth doc fragment

* Use doc fragment.

Co-authored-by: Julian Faude <[email protected]>
Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 9a74ace)

Co-authored-by: jcharlytown <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database docs_fragments docs_fragments plugin (shared docs) feature This issue/PR relates to a feature request module_utils module_utils module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants