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 options support #52

Merged
merged 1 commit into from
Apr 2, 2016
Merged

add options support #52

merged 1 commit into from
Apr 2, 2016

Conversation

b4ldr
Copy link
Member

@b4ldr b4ldr commented Feb 23, 2016

This pull request allows on to add values to Dpkg::Options, specifically --force-conf*

@@ -4,13 +4,15 @@
if $::osfamily != 'Debian' {
fail('This module only works on Debian or derivatives like Ubuntu')
}

Copy link
Member

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.

@daenney
Copy link
Member

daenney commented Feb 29, 2016

This is missing tests and documentation.

@b4ldr
Copy link
Member Author

b4ldr commented Mar 1, 2016

tests and documentation added

@jyaworski
Copy link
Member

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?

@b4ldr
Copy link
Member Author

b4ldr commented Mar 1, 2016

@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
[2]https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/is_bool.rb#L16

@daenney
Copy link
Member

daenney commented Mar 1, 2016

Why are we complicating this so much? If the value is actually false, as in the false in Puppet value in the ERB will be falsey, else truthy. Since we've already validated that it's a bool in the Puppet manifest, we don't need any additional checks to figure out if it's a TrueClass or a FalseClass, it's already guaranteed as it wouldn't pass the validate_bool otherwise.

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 -%>
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@daenney @jyaworski hows that?

Copy link
Member

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'])

Copy link
Member

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.

Copy link
Member Author

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 :)

@daenney
Copy link
Member

daenney commented Mar 1, 2016

This looks good. One quick question, we're default to confed and confold to being true. That's the default behaviour?

@b4ldr
Copy link
Member Author

b4ldr commented Mar 1, 2016

@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

@daenney
Copy link
Member

daenney commented Mar 1, 2016

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.

@b4ldr
Copy link
Member Author

b4ldr commented Mar 1, 2016

Happy to follow advice here i am far from an expert in apt or dpkg

@jyaworski
Copy link
Member

Ping @daenney

@jyaworski
Copy link
Member

This needs rebased.

fix ruby 1.9 hash

correct
@b4ldr
Copy link
Member Author

b4ldr commented Mar 31, 2016

rebased

@jyaworski jyaworski merged commit 9c9c140 into voxpupuli:master Apr 2, 2016
@anarcat
Copy link
Contributor

anarcat commented Aug 15, 2021

@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.

sorry to take old skeletons out of the closet, but i think this is not quite correct, and out of scope of this module. --force-confold applies not only to unattended-upgrades run (which is, in fact, unaffected by it) but also all dpkg runs, which seems rather overkill.

i don't see why the unattended-upgrades module should mess with dpkg settings in the first place. this seems unnecessary and confusing. i was surprised to notice this, actually, and it might strike people as odd, in general.

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.

@anarcat anarcat mentioned this pull request Aug 15, 2021
@anarcat
Copy link
Contributor

anarcat commented Aug 15, 2021

followup discussion in #190.

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.

4 participants