Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremyolliver/7fe94757d7a1425c9123 to your computer and use it in GitHub Desktop.
Save jeremyolliver/7fe94757d7a1425c9123 to your computer and use it in GitHub Desktop.
override['unattended-upgrades']['allowed_origins']['add-this-one'] = true
override['unattended-upgrades']['allowed_origins']['security'] = false # Turn off the default value
default['unattended-upgrades']['allowed_origins'] = {
'security' => true,
'updates' => false,
'proposed' => false,
'backports' => false
}
@jeremyolliver
Copy link
Author

Example of the pattern of using a hash, instead of an array to specify a list of values. The cookbook implementation needs to check the truthy value each item in the hash points to, and either remove or ignore the falsy values. e.g. https://github.com/jeremyolliver/cookbook-unattended-upgrades/blob/master/attributes/default.rb#L11-L16

This makes deep merging and attribute precedence easier to deal with because changing the defaults can now point to only the value they wish to addd or subtract, without having to specify the entire list (which may have already been overridden).

The alternate solution of using the array ['security', 'updates', 'proposed', 'backports'] is harder to change, because depending on the precedence level where you try to change the defaults, either the array might be replaced (meaning you would need to know the entire value, making your changes not composable), or the two arrays might be merged together, which only works for adding in new values, subtracting is a nightmare.

@fujin
Copy link

fujin commented May 20, 2014

lol fuck this

@jeremyolliver
Copy link
Author

I typically would alter the defaults as shown above with an override statement either in an attribute or recipe file of an 'application' cookbook.The same should also work, altering the defaults via a role or environment too.

@fujin
Copy link

fujin commented May 20, 2014

this is why we can't have nice things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment