10 changes: 3 additions & 7 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
fixtures:
forge_modules:
stdlib:
repo: "puppetlabs-stdlib"
ref: "4.6.0"
apt:
repo: "puppetlabs-apt"
ref: "2.2.0"
repositories:
apt: 'https://github.com/puppetlabs/puppetlabs-apt.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
symlinks:
unattended_upgrades: "#{source_dir}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pkg/
Gemfile.lock
Gemfile.local
vendor/
.vendor/
spec/fixtures/
.vagrant/
.bundle/
Expand Down
25 changes: 20 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require: rubocop-rspec
AllCops:
TargetRubyVersion: 1.9
Include:
- ./**/*.rb
Exclude:
- vendor/**/*
- .vendor/**/*
- pkg/**/*
- spec/fixtures/**/*

Expand All @@ -26,18 +29,20 @@ Metrics/AbcSize:
Metrics/MethodLength:
Enabled: false

# Module length is not necessarily an indicator of code quality
Metrics/ModuleLength:
Enabled: false

# Class length is not necessarily an indicator of code quality
Metrics/ClassLength:
Enabled: false

# dealbreaker:
Style/TrailingComma:
Style/TrailingCommaInArguments:
Enabled: false
Style/ClosingParenthesisIndentation:
Style/TrailingCommaInLiteral:
Enabled: false

# we still support ruby 1.8
Style/HashSyntax:
Style/ClosingParenthesisIndentation:
Enabled: false

Lint/AmbiguousRegexpLiteral:
Expand All @@ -62,3 +67,13 @@ Style/BlockDelimiters:

Style/MultilineBlockLayout:
Enabled: False

# Rspec

# We don't use rspec in this way
RSpec/DescribeClass:
Enabled: False

# Example length is not necessarily an indicator of code quality
RSpec/ExampleLength:
Enabled: False
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@
sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests
before_install: rm Gemfile.lock || true
bundler_args: --without system_tests development
before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.1.7
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test
- rvm: 2.1
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.1.7
- rvm: 2.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.2.3
- rvm: 2.2
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.2.3
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=rubocop
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
notifications:
email: false
deploy:
Expand All @@ -31,4 +41,4 @@ deploy:
# all_branches is required to use tags
all_branches: true
# Only publish if our main Ruby target builds
rvm: 1.9.3
rvm: 2.2
1 change: 1 addition & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--markup markdown
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]

## Release 2.0.0 - 2016-05-26
- Drop Ruby1.8 Support
- Modulesync to latest voxpupuli defaults
- Improve spec tests
- Update documentation
- Add parameter to control reboot time
- Update default parameters for legacy_origin option
- Add options support

## Release 1.1.1 - 2016-01-11
### Changed
- CHANGELOG: Fixed comparison URL's for the releases
Expand Down
20 changes: 16 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,29 @@ The test suite will run [Puppet Lint](http://puppet-lint.com/) and
[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
check various syntax and style things. You can run these locally with:

bundle exec rake test
bundle exec rake lint
bundle exec rake validate

## Running the unit tests

The unit test suite covers most of the code, as mentioned above please
add tests if you're adding new functionality. If you've not used
[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
about how best to test your new feature. To run your specific spec test
you can pass it to `SPEC`:
about how best to test your new feature.

To run your all the unit tests

bundle exec rake spec SPEC_OPTS='--format documentation'

To run a specific spec test set the `SPEC` variable:

bundle exec rake spec SPEC=spec/foo_spec.rb

To run the linter, the syntax checker and the unit tests:

bundle exec rake test


## Integration tests

The unit tests just check the code runs, not that it does exactly what
Expand All @@ -76,10 +87,11 @@ with:
This will run the tests on an Ubuntu 12.04 virtual machine. You can also
run the integration tests against Centos 6.5 with.

RS_SET=centos-64-x64 bundle exec rake acceptances
BEAKER_set=centos-64-x64 bundle exec rake acceptances

If you don't want to have to recreate the virtual machine every time you
can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will
at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile
for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`.

# vim: syntax=markdown
19 changes: 9 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'rake', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', :require => false, :git => 'https://github.com/rodjek/rspec-puppet.git'
gem 'puppet-lint', :require => false, :git => 'https://github.com/rodjek/puppet-lint.git'
gem 'metadata-json-lint', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec', :require => false
gem 'puppet-blacksmith', :require => false, :git => 'https://github.com/voxpupuli/puppet-blacksmith.git'
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git'
gem 'rubocop', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false, :git => 'https://github.com/rodjek/puppet-lint.git'
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet-blacksmith', :require => false, :git => 'https://github.com/voxpupuli/puppet-blacksmith.git'
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git'
gem 'puppet-strings', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs-strings.git'
gem 'rubocop-rspec', '~> 1.5', :require => false
end

group :development do
Expand Down Expand Up @@ -58,7 +57,7 @@ else
gem 'facter', :require => false, :groups => [:test]
end

ENV['PUPPET_VERSION'].nil? ? puppetversion = '3.8.4' : puppetversion = ENV['PUPPET_VERSION'].to_s
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
gem 'puppet', puppetversion, :require => false, :groups => [:test]

# vim:ft=ruby
# vim: syntax=ruby
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Using unattended\_upgrades simply consists of including the module and if needed
* `clean`(`0`): Remove packages that can no longer be downloaded from cache every X days (`0` = disabled).
* `fix_interrupted_dpkg`(`true`): Try to fix package installation state.
* `reboot`(`false`): Reboot system after package update installation.
* `reboot_time`(`now`): If automatic reboot is enabled and needed, reboot at the specific time (instead of immediately).
* `remove`(`true`): Remove unneeded dependencies after update installation.

Any of these keys can be specified and will be merged into the defaults:
Expand All @@ -77,7 +78,7 @@ Using unattended\_upgrades simply consists of including the module and if needed
* `dl_limit`(`undef`): Use a bandwidth limit for downloading, specified in kb/sec.
* `enable` (`1`): Enable the automatic installation of updates.
* `install_on_shutdown` (`false`): Install updates on shutdown instead of in the background.
* `legacy_origin` (`false`): Use the legacy `Unattended-Upgrade::Allowed-Origins` setting or the modern `Unattended-Upgrade::Origins-Pattern`.
* `legacy_origin` (`true` for Debian (squeeze), Ubuntu (precise, trusty, utopic, vivid, wily and default), `false`for Debian (wheezy and default)): Use the legacy `Unattended-Upgrade::Allowed-Origins` setting or the modern `Unattended-Upgrade::Origins-Pattern`.
* `mail`: A hash to configure email behaviour with two possible keys:
* `only_on_error` (`true`): Only send mail when something went wrong
* `to` (`undef`): Email address to send email too
Expand All @@ -93,7 +94,7 @@ Using unattended\_upgrades simply consists of including the module and if needed
* `minimal_steps` (`true`): Split the upgrade process into sections to allow shutdown during upgrade.
* `origins`: The repositories from which to automatically upgrade included packages.
* `package_ensure` (`installed`): The ensure state for the 'unattended-upgrades' package.
* `random_sleep` (`300`): Maximum amount of time (in seconds) that the apt cron job can sleep before the execution. The exact amount of time will be random but upto the value specified. The purpose is to avoid that servers/mirrors get hammered at exactly the same time when a lot of machines are switched on, e.g. 9:00 in the morning.
* `random_sleep` (`undef`): Maximum amount of time (in seconds) that the apt cron job can sleep before the execution. The exact amount of time will be random but upto the value specified. The purpose is to avoid that servers/mirrors get hammered at exactly the same time when a lot of machines are switched on, e.g. 9:00 in the morning. Note: If this is left unset, the default value in the apt cron job applies, which is 1800 seconds.
* `size` (`0`): Maximum size of the cache in MB.
* `update` (`1`): Do "apt-get update" automatically every n-days.
* `upgrade` (`1`): Run the "unattended-upgrade" security upgrade script every n-days.
Expand All @@ -108,6 +109,13 @@ Using unattended\_upgrades simply consists of including the module and if needed
}
```
* `verbose` (`0`): Send report mail to root.
* `options` (`{}`): A hash of settings with these possible keys:
* `force_confdef` (`true`) : Use the default option for new config files if one
is available, don't prompt. If no default can be found, you will be prompted
unless one of the confold or confnew options is also given
* `force_confold` (`true`): Always use the old config files, don't prompt
* `force_connew` (`false`): Always use the new config files, don't prompt
* `force_conmiss` (`false`): Always install missing config files

## Limitations

Expand Down
15 changes: 9 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'metadata-json-lint/rake_task'
require 'puppet_blacksmith/rake_tasks'
require 'voxpupuli/release/rake_tasks'
require 'rubocop/rake_task'
require 'puppet-strings/rake_tasks'

RuboCop::RakeTask.new
RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['-D', '-S', '-E']
end

PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')

exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
spec/**/*
)
PuppetLint.configuration.ignore_paths = exclude_paths
Expand All @@ -29,10 +31,11 @@ RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

desc 'Run metadata_lint, lint, syntax, and spec tests.'
desc 'Run tests metadata_lint, lint, syntax, spec'
task test: [
:metadata_lint,
:lint,
:syntax,
:spec,
]
# vim: syntax=ruby
15 changes: 14 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
$upgrade = 1,
$upgradeable_packages = {},
$verbose = 0,
$notify_update = undef,
$notify_update = false,
$options = {},
) inherits ::unattended_upgrades::params {

if $legacy_origin == undef or $origins == undef {
Expand Down Expand Up @@ -45,6 +46,12 @@
validate_integer($size)
validate_hash($upgradeable_packages)
$_upgradeable_packages = merge($::unattended_upgrades::default_upgradeable_packages, $upgradeable_packages)
validate_hash($options)
$_options = merge($unattended_upgrades::default_options, $options)
validate_bool($_options['force_confdef'])
validate_bool($_options['force_confold'])
validate_bool($_options['force_confnew'])
validate_bool($_options['force_confmiss'])

package { 'unattended-upgrades':
ensure => $package_ensure,
Expand All @@ -70,5 +77,11 @@
require => Package['unattended-upgrades'],
notify_update => $notify_update,
}
apt::conf { 'options':
priority => 10,
content => template("${module_name}/options.erb"),
require => Package['unattended-upgrades'],
notify_update => $notify_update,
}

}
7 changes: 5 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
fail('This module only works on Debian or derivatives like Ubuntu')
}

$default_auto = { 'fix_interrupted_dpkg' => true, 'remove' => true, 'reboot' => false, 'clean' => 0, }
$default_auto = { 'fix_interrupted_dpkg' => true, 'remove' => true, 'reboot' => false, 'clean' => 0, 'reboot_time' => 'now', }
$default_mail = { 'only_on_error' => true, }
$default_backup = { 'archive_interval' => 0, 'level' => 3, }
$default_age = { 'min' => 2, 'max' => 0, }
$default_upgradeable_packages = { 'download_only' => 0, 'debdelta' => 1, }

$default_options = { 'force_confdef' => true,
'force_confold' => true,
'force_confnew' => false,
'force_confmiss' => false, }
# prior to puppet 3.5.0, defined couldn't test if a variable was defined
# strict variables wasn't added until 3.5.0, so this should be fine.
if ! $::settings::strict_variables {
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "puppet-unattended_upgrades",
"version": "1.1.1",
"version": "2.0.0",
"author": "voxpupuli",
"summary": "Provides an interface for managing Apt unattended_upgrades with Puppet",
"license": "Apache-2.0",
"source": "https://github.com/voxpupuli/puppet-unattended_upgrades",
"source": "https://github.com/voxpupuli/puppet-unattended_upgrades.git",
"project_page": "https://github.com/voxpupuli/puppet-unattended_upgrades",
"issues_url": "https://github.com/voxpupuli/puppet-unattended_upgrades/issues",
"operatingsystem_support": [
Expand Down
12 changes: 12 additions & 0 deletions spec/acceptance/nodesets/centos-511-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
HOSTS:
centos-511-x64:
roles:
- master
platform: el-5-x86_64
box: puppetlabs/centos-5.11-64-nocm
hypervisor: vagrant
CONFIG:
type: foss
...
# vim: syntax=yaml
Loading