-
-
Notifications
You must be signed in to change notification settings - Fork 500
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 optional variables for SSL management-console #648
Conversation
👍 from me, can you squash that second commit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, can you squash that last commit?
manifests/init.pp
Outdated
@@ -243,7 +246,10 @@ | |||
$ssl_port = $rabbitmq::params::ssl_port, | |||
Optional[String] $ssl_interface = undef, | |||
Integer $ssl_management_port = $rabbitmq::params::ssl_management_port, | |||
Integer $ssl_stomp_port = $rabbitmq::params::ssl_stomp_port, | |||
Optional[String] $ssl_management_cacert = $ssl_cacert, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this could introduce any weird behavior. This is undef by default, since the params you're referencing are undef, but if someone set ssl_cacert
and tried to explicitly set ssl_management_cacert
to undef
, it wouldn't work. I think this is still probably the best and most logical behavior (to take those as defaults).
16b720c
to
5fbdf22
Compare
@wyardley thx for reviewing. You are right, its was not possible to not set an CA Cert for the mgmnt. |
@slm0n87 maybe you could make it undef, and then, in the manifest, set it to the value of the other one? I think setting it to false vs. undef is kind of an anti-pattern, @bastelfreak @alexjfisher - any thoughts on the best way to accomplish this? |
manifests/init.pp
Outdated
@@ -243,7 +247,10 @@ | |||
$ssl_port = $rabbitmq::params::ssl_port, | |||
Optional[String] $ssl_interface = undef, | |||
Integer $ssl_management_port = $rabbitmq::params::ssl_management_port, | |||
Integer $ssl_stomp_port = $rabbitmq::params::ssl_stomp_port, | |||
Variant[Undef, Boolean, String] $ssl_management_cacert = $ssl_cacert, | |||
Optional[String] $ssl_management_cert = $ssl_cert, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all params should be alligned at their =
@wyardley I agree, this is an antipattern and should be avoided. |
I think you could do it this way:
That make sense? |
See also some changes in #649 that may affect this or require a rebase. Basically, I think the cert params should be |
manifests/init.pp
Outdated
@@ -243,7 +247,10 @@ | |||
$ssl_port = $rabbitmq::params::ssl_port, | |||
Optional[String] $ssl_interface = undef, | |||
Integer $ssl_management_port = $rabbitmq::params::ssl_management_port, | |||
Integer $ssl_stomp_port = $rabbitmq::params::ssl_stomp_port, | |||
Variant[Undef, Boolean, String] $ssl_management_cacert = $ssl_cacert, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's some issue trying to default one parameter based on another like this. @bastelfreak this came up on IRC IIRC??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, since puppet 4.4.0 (I've been go back through the IRC logs), this should work. https://github.com/puppetlabs/puppet-specifications/blob/master/language/parameter_scope.md#the-default-expression-evaluation.
It took me a little while to figure out why the If I understand correctly, you need to default all the parameters to the existing ones for backwards compatibility and because that's what most people will want to do anyway. But you also want to account for users who want no ssl_management_cacert file. If you explicitly try to set the parameter to undef, nothing happens, you just get the parameter default. So you've got to allow |
I think if the boolean It doesn't look like the templates support the case where these don't exist, e.g.:
|
- move logic for backwards compatibility into the manifest
reopen Issie (accidentally closed by forced rebasing my forked master)... |
I updated my patch once more by moving the overwrites for backwards compatibility into the manifest and set them to undef by default. |
templates/rabbitmq.config.erb
Outdated
@@ -109,11 +109,11 @@ | |||
<%- end -%> | |||
{port, <%= @ssl_management_port %>}, | |||
{ssl, true}, | |||
{ssl_opts, [<%- if @ssl_cacert %> | |||
{cacertfile, "<%= @ssl_cacert %>"}, | |||
{ssl_opts, [<%- if @_ssl_management_cacert %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think regardless of how it's coded, ssl_management_cacert
can't actually be undef, right? since it still defaults to ssl_cacert
if it's not defined?
@slm0n87 I think this will work, but I think @alexjfisher is right that this still won't allow actually suppressing it, because of the way the defaults work. Given that, I think the bit I commented on in the template is maybe extraneous? Also, the module supports >= 4.7.1 only, so maybe using the default in the params is cleaner after all, though I'm Ok with it as it is here. Sorry for so much back and forth on this PR, and thanks for all the revisions. |
@wyardley thx for the feedback - you are welcome. regarding the forth and back, I am aware of the conflict keeping a module most configurablae but backwards compatible :) |
- based on discussions in voxpupuli#648
like this slm0n87@3d5ba4b |
@slm0n87 yeah, I think that makes some sense. Having a param was the way I was thinking of suggesting. The current template doesn't seem to support suppressing the cafile, so I think it could be Ok if that's not supported, but maybe you need that feature? |
- based on discussions in voxpupuli#648
- based on discussions in voxpupuli#648
- based on discussions in voxpupuli#648
- based on discussions in voxpupuli#648
@slm0n87 Great, two questions then:
|
I am not deep enough into spec tests to be able to write tests for my pullrequest. It would be perfect if someone could overtake this which also gives me a good example. |
manifests/config.pp
Outdated
$ssl_port = $rabbitmq::ssl_port | ||
$ssl_interface = $rabbitmq::ssl_interface | ||
$ssl_management_port = $rabbitmq::ssl_management_port | ||
$ssl_management_cacert_enable = $rabbitmq::ssl_management_cacert_enable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add datatypes for the new params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is because they're not class params, but variables in config.pp
. in init.pp
, these all have data types. IIRC, you can't specify data types for variables vs. class params. I think they're not settable since they're in the body of the manifest, though we could also add an explicit assert_private()
too maybe?
I can work on this at some point if I've got the time and submit a PR to your PR. FWIW, I think this is the section, so it might not be as bad as you think to make cases for the specific use cases. While I don't mind adding them, I think it can actually be a pretty useful exercise to add tests yourself. You'd want to create a https://github.com/voxpupuli/puppet-rabbitmq/blob/master/spec/classes/rabbitmq_spec.rb#L721-L1135
Ah, you're right, misread that before. So this solves the case of needing to suppress the CA cert for the management in the case where the main SSL config needs it but management doesn't. |
- based on discussions in voxpupuli#648
- fallback to old variable for backwards compatibility
@wyardley @bastelfreak @alexjfisher can you review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, can you explain the one comment I have (inline)?
Fixes #564