-
Notifications
You must be signed in to change notification settings - Fork 74
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 options support #52
Conversation
@@ -4,13 +4,15 @@ | |||
if $::osfamily != 'Debian' { | |||
fail('This module only works on Debian or derivatives like Ubuntu') | |||
} | |||
|
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.
Please leave the new line in place.
This is missing tests and documentation. |
tests and documentation added |
I think this looks good now, but I'm still really wary of what @daenney mentioned. Looking into it, that really does appear to be the only way to do it in ruby. Would it be possible to call puppet's validate_bool? |
@jyaworski, I updated the boolean check to use the following which is the same code that validate_bool eventully runs if value.is_a?(TrueClass) || value.is_a?(FalseClass) then validate_bool calls is_bool[1] which does the same as above[2] [1]https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/validate_bool.rb#L27 |
Never mind, there's too many things named value that are being checked for things, this is getting confusing. |
<%- @_options.each_pair do |config, value| | ||
if %w(force_confdef force_confold force_confnew force_confmiss).include?(config) then | ||
if value.is_a?(TrueClass) || value.is_a?(FalseClass) then | ||
if value then -%> |
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.
Why is there an additional check here? We've already checked if they're a boolean or not so they contain a value.
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.
We check if it is a boolean or not so that we can provide a usefull error message to the user i.e. this value must be a boolean. We then we check if the value is true.
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 could add individual checks in the puppet manifest like
validate_bool($options['force_confdef'])
validate_bool($options['force_confold'])
validate_bool($options['force_confnew'])
validate_bool($options['force_confmiss'])
And remove the check in the erb if you would prefer
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.
@b4ldr I would prefer in-manifest checks.
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.
@daenney @jyaworski hows that?
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.
As you mentioned earlier:
validate_bool($options['force_confdef'])
validate_bool($options['force_confold'])
validate_bool($options['force_confnew'])
validate_bool($options['force_confmiss'])
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.
We check if it is a boolean or not so that we can provide a usefull error message to the user i.e. this value must be a boolean. We then we check if the value is true.
Ah, I see what you're getting at.
And yes, I'd be happier with 4 validate_bool
calls actually, catch it as early as possible so we keep the logic in the template to a minimum. This could further be improved once we start moving to Puppet 4 only for our modules and leverage the type system instead.
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.
As you mentioned earlier:
Yes i have made the update, i meant is it ok now?
And yes, I'd be happier with 4 validate_bool calls actually
done :)
This looks good. One quick question, we're default to |
@daenney I think the default behaviour is confdef true and everything else false. This means that apt will always ask you what to do if there is a conflict. I set confold to true because it makes most sense in a puppet world i.e. you are probably managing config files and you want your managed config to stay. But i can also see the argument that we should keep everything default and let the user choose. happy to change if you prefer |
I'll take a look at what the default behaviour is. We should ensure to mimic that so we don't surprise users with different behaviour. We can introduce new features without major version bumps but we have to be careful to not introduce them in such a way that they would alter anything. We can always flip that default on a major version bump and in the mean time have a recommended settings entry in the README instead. |
Happy to follow advice here i am far from an expert in apt or dpkg |
Ping @daenney |
This needs rebased. |
fix ruby 1.9 hash correct
rebased |
sorry to take old skeletons out of the closet, but i think this is not quite correct, and out of scope of this module. i don't see why the unattended-upgrades module should mess with this could be particularly bad if someone tries to do manual upgrades, which are still necessary in some cases (for example during major upgrades), as new configs will fail to be deployed, which may certainly cause breakage. i'll see if i can make a PR to fix this, but i'm afraid the simplest would just be to back this out completely. |
followup discussion in #190. |
This pull request allows on to add values to Dpkg::Options, specifically --force-conf*