Merge pull request #657 from puppetlabs/binford2k-patch-1
authorTP Honey <tphoney@users.noreply.github.com>
Tue, 26 Sep 2017 09:23:47 +0000 (10:23 +0100)
committerGitHub <noreply@github.com>
Tue, 26 Sep 2017 09:23:47 +0000 (10:23 +0100)
This class should be private

51 files changed:
.gitattributes
.sync.yml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile
NOTICE
README.md
lib/facter/apt_updates.rb
lib/puppet/provider/apt_key/apt_key.rb
locales/config.yaml [new file with mode: 0644]
manifests/backports.pp
manifests/conf.pp
manifests/init.pp
manifests/key.pp
manifests/params.pp
manifests/pin.pp
manifests/ppa.pp
manifests/setting.pp
manifests/source.pp
manifests/update.pp
metadata.json
spec/acceptance/apt_spec.rb
spec/classes/apt_backports_spec.rb
spec/classes/apt_spec.rb
spec/classes/apt_update_spec.rb
spec/classes/params_spec.rb [deleted file]
spec/defines/conf_spec.rb
spec/defines/key_compat_spec.rb
spec/defines/key_spec.rb
spec/defines/pin_spec.rb
spec/defines/ppa_spec.rb
spec/defines/setting_spec.rb
spec/defines/source_compat_spec.rb
spec/defines/source_spec.rb
spec/unit/facter/apt_has_updates_spec.rb
spec/unit/facter/apt_package_security_updates_spec.rb [new file with mode: 0644]
spec/unit/facter/apt_package_updates_spec.rb
spec/unit/facter/apt_security_updates_spec.rb
spec/unit/facter/apt_update_last_success_spec.rb
spec/unit/facter/apt_updates_spec.rb
templates/15update-stamp.epp [moved from templates/15update-stamp.erb with 100% similarity]
templates/_conf_header.epp [moved from templates/_conf_header.erb with 100% similarity]
templates/_header.epp [moved from templates/_header.erb with 100% similarity]
templates/conf.erb [deleted file]
templates/pin.pref.epp [new file with mode: 0644]
templates/pin.pref.erb [deleted file]
templates/proxy.epp [new file with mode: 0644]
templates/proxy.erb [deleted file]
templates/source.list.epp [new file with mode: 0644]
templates/source.list.erb [deleted file]

index 900ea0cbb54170c6e19d28dfcaa231774b70952e..02d4646b9b24d9721ad8381a430d90f7d7cbf845 100644 (file)
@@ -1,5 +1,5 @@
 #This file is generated by ModuleSync, do not edit.
-*.rb  eol=lf
+*.rb eol=lf
 *.erb eol=lf
-*.pp  eol=lf
-*.sh  eol=lf
+*.pp eol=lf
+*.sh eol=lf
index 1c79b46b328edb2445998e2d9d9b0d1f17ccb3ac..dd596277d31bc7a8364c03475e78bb6d52347b20 100644 (file)
--- a/.sync.yml
+++ b/.sync.yml
@@ -7,5 +7,8 @@ appveyor.yml:
   - set: docker/ubuntu-14.04
   - set: docker/debian-8
 
+NOTICE:
+  unmanaged: true
+
 spec/spec_helper.rb:
   allow_deprecations: true
index 115691d393be4b1af98560703842c6a9a2cc9937..9af2623346e9f99b2ec1de6c65724024f09610fc 100644 (file)
@@ -22,10 +22,10 @@ matrix:
     script: bundle exec rake beaker
     services: docker
     sudo: required
-  - rvm: 2.3.1
+  - rvm: 2.4.0
     bundler_args: --without system_tests
-    env: PUPPET_GEM_VERSION="~> 4.0"
-  - rvm: 2.1.7
+    env: PUPPET_GEM_VERSION="~> 5.0"
+  - rvm: 2.1.9
     bundler_args: --without system_tests
     env: PUPPET_GEM_VERSION="~> 4.0"
 notifications:
index 44cc4f8f71120c82cdead8602875a38ff2e765f7..3473175318d22b94dc5e080ce9e9b1f49f05d303 100644 (file)
@@ -1,3 +1,55 @@
+## Supported Release 4.1.0
+### Summary
+
+This release removes Data in Modules due to current compatibility issues and reinstates the params.pp file. Also includes a couple of bug fixes.
+
+#### Features
+- (MODULES-4973) Data in Modules which was introduced in the last release has now been reverted due to compatibility issues.
+
+#### Bugfixes
+- Now apt_key only sends the auth basic header when userinfo can be parsed from the URL.
+- Reverted the removal of Evolving Web's attribution in NOTICE file.
+- Test added to ensure empty string allowed for $release in apt::source.
+
+
+## Supported Release 3.0.0 and 4.0.0
+### Summary
+
+This release adds new Puppet 4 features: data in modules, EPP templates, the $facts hash, and data types. This release is fully backwards compatible to existing Puppet 4 configurations and provides you with deprecation warnings for every argument that will not work as expected with the final 4.0.0 release. See the stdlib docs here for an in-depth discussion of this: https://github.com/puppetlabs/puppetlabs-stdlib#validate_legacy
+
+If you want to learn more about the new features used or you wish to upgrade a module yourself, have a look at the NTP: A Puppet 4 language update blog post.
+
+If you're still running Puppet 3, remain on the latest puppetlabs-apt 2.x release for now, and see the documentation to upgrade to Puppet 4.
+
+#### Changes
+
+Data in modules: Moves all distribution and OS-dependent defaults into YAML files in data/, alleviating the need for a params class. Note that while this feature is currently still classed as experimental, the final implementation will support the changes here.
+EPP templating: Uses the Puppet language as a base for templates to create simpler and safer templates. No need for Ruby anymore!
+The $facts hash: Makes facts visibly distinct from other variables for more readable and maintainable code. This helps eliminate confusion if you use a local variable whose name happens to match that of a common fact.
+Data types for validation: Helps you find and replace deprecated code in existing validate functions with stricter, more readable data type notation. First upgrade to the 3.0.0 release of this module, and address all deprecation warnings before upgrading to the final 4.0.0 release. Please see the stdlib docs for an in-depth discussion of this process.
+
+#### Bugfixes
+- Fix apt::source epp template regression introduced in 3.0.0 for the architecture parameter
+
+## Supported Release 2.4.0
+### Summary
+A release that includes only a couple of additional features, but includes several cleanups and bugfixes around existing issues.
+
+#### Features
+- Tests updated to check for idempotency.
+- (MODULES-4224) Implementation of beaker-module_install_helper.
+- Deprecation warnings are now handled by the deprecation function in stdlib.
+
+#### Bugfixes
+- Now http and https sources fixed for apt_key and can take a userinfo.
+- GPG key update.
+- Notify_update param now defaults to true to avoid validation errors.
+- Implement retry on tests which pull key from a key server which sometimes times out (transient error).
+- String comparison error now comphensated for in update.pp.
+- (MODULES-4104) Removal of the port number from repository location in order to get the host name of the repository.
+- Puppet lint warnings addressed.
+- A few small readme issues addressed.
+
 ## Supported Release 2.3.0
 ### Summary
 A release containing many bugfixes with additional features.
@@ -21,12 +73,12 @@ A release containing many bugfixes with additional features.
 - Replaced `-s` with `-f` in ppa rspec tests - After the repository is added, the "${::apt::sources_list_d}/${sources_list_d_filename}" file is created as an empty file. The unless condition of Exec["add-apt-repository-${name}"] calls test -s, which returns 1 if the file is empty. Because the file is empty, the unless condition is never true and the repository is added on every execution. This change replaces the -s test condition with -f, which is true if the file exists or false otherwise.
 - Limit non-strict parsing to pre-3.5.0 only - Puppet 3.5.0 introduced strict variables and the module handles strict variables by using the defined() function. This does not work on prior versions of puppet so we now gate based on that version. Puppet 4 series has a new setting `strict` that may be set to enforce strict variables while `strict_variables` remains unset (see PUP-6358) which causes the conditional in manifests/params.pp to erroniously use non-strict 3.5-era parsing and fail. This new conditional corrects the cases such that strict variable behavior happens on versions 3.5.0 and later.
 
-##Supported Release 2.2.2
-###Summary
+## Supported Release 2.2.2
+### Summary
 
 Several bug fixes and the addition of support updates to Debian 8 and Ubuntu Wily.
 
-####Bugfixes
+#### Bugfixes
 - Small fixes to descriptions within the readme and the addition of some examples.
 - Updates to run on Ubuntu Wily.
 - Fixed apt_key tempfile race condition.
@@ -40,92 +92,92 @@ Several bug fixes and the addition of support updates to Debian 8 and Ubuntu Wil
 - Look for correct sources.list.d file for apt::ppa.
 - Debian 8 support addiiton to metadata.
 
-##Supported Release 2.2.1
-###Summary
+## Supported Release 2.2.1
+### Summary
 
 Small release for support of newer PE versions. This increments the version of PE in the metadata.json file.
 
-##2015-09-29 - Supported Release 2.2.0
-###Summary
+## 2015-09-29 - Supported Release 2.2.0
+### Summary
 
 This release includes a few bugfixes.
 
-####Features
+#### Features
 - Adds an `ensure` parameter for user control of proxy presence.
 - Adds ability to set `notify_update` to `apt::conf` (MODULES-2269).
 - Apt pins no longer trigger an `apt-get update` run.
 - Adds support for creating pins from main class.
 
-####Bugfixes
+#### Bugfixes
 - Updates to use the official Debian mirrors.
 - Fixes path to `preferences` and `preferences.d`
 - Fixes pinning for backports (MODULES-2446).
 - Fixes the name/extension of the preferences files.
 
-##2015-07-28 - Supported Release 2.1.1
-###Summary
+## 2015-07-28 - Supported Release 2.1.1
+### Summary
 
 This release includes a few bugfixes.
 
-####Bugfixes
+#### Bugfixes
 - Fix incorrect use of anchoring (MODULES-2190)
 - Use correct comment type for apt.conf files
 - Test fixes
 - Documentation fixes
 
-##2015-06-16 - Supported Release 2.1.0
-###Summary
+## 2015-06-16 - Supported Release 2.1.0
+### Summary
 
 This release largely makes `apt::key` and `apt::source` API-compatible with the 1.8.x versions for ease in upgrading, and also addresses some compatibility issues with older versions of Puppet.
 
-####Features
+#### Features
 - Add API compatibility to `apt::key` and `apt::source`
 - Added `apt_reboot_required` fact
 
-####Bugfixes
+#### Bugfixes
 - Fix compatibility with Puppet versions 3.0-3.4
 - Work around future parser bug PUP-4133
 
-##2015-04-28 - Supported Release 2.0.1
-###Summary
+## 2015-04-28 - Supported Release 2.0.1
+### Summary
 
 This bug fixes a few compatibility issues that came up with the 2.0.0 release, and includes test and documentation updates.
 
-####Bugfixes
+#### Bugfixes
 - Fix incompatibility with keyrings containing multiple keys
 - Fix bugs preventing the module from working with Puppet < 3.5.0
 
-##2015-04-07 - Supported Release 2.0.0
-###Summary
+## 2015-04-07 - Supported Release 2.0.0
+### Summary
 
 This is a major rewrite of the apt module. Many classes and defines were removed, but all existing functionality should still work. Please carefully review documentation before upgrading.
 
-####Backwards-incompatible changes
+#### Backwards-incompatible changes
 
 As this is a major rewrite of the module there are a great number of backwards incompatible changes. Please review this and the updated README carefully before upgrading.
 
-#####`apt_key`
+##### `apt_key`
 - `keyserver_options` parameter renamed to `options`
 
-#####`apt::backports`
+##### `apt::backports`
 - This no longer works out of the box on Linux Mint. If using this on mint, you must specify the `location`, `release`, `repos`, and `key` parameters. [Example](examples/backports.pp)
 
-#####`apt::builddep`
+##### `apt::builddep`
 - This define was removed. Functionality can be matched passing 'build-dep' to `install_options` in the package resource. [Example](examples/builddep.pp)
 
-#####`apt::debian::testing`
+##### `apt::debian::testing`
 - This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_testing.pp)
 
-#####`apt::debian::unstable`
+##### `apt::debian::unstable`
 - This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_unstable.pp)
 
-#####`apt::force`
+##### `apt::force`
 - This define was removed. Functionallity can be matched by setting `install_options` in the package resource. See [here](examples/force.pp) for how to set the options.
 
-#####`apt::hold`
+##### `apt::hold`
 - This define was removed. Simply use an `apt::pin` with `priority => 1001` for the same functionality.
 
-#####`apt`
+##### `apt`
 - `always_apt_update` - This parameter was removed. Use `update => { 'frequency' => 'always' }` instead.
 - `apt_update_frequency` - This parameter was removed. Use `update => { 'frequency' => <frequency> }` instead.
 - `disable_keys` - This parameter was removed. See this [example](examples/disable_keys.pp) if you need this functionality.
@@ -138,17 +190,17 @@ As this is a major rewrite of the module there are a great number of backwards i
 - `update_timeout` - This parameter was removed. Use `update => { 'timeout' => <timeout> }` instead.
 - `update_tries` - This parameter was removed. Use `update => { 'tries' => <tries> }` instead.
 
-#####`apt::key`
+##### `apt::key`
 - `key` - This parameter was renamed to `id`.
 - `key_content` - This parameter was renamed to `content`.
 - `key_source` - This parameter was renamed to `source`.
 - `key_server` - This parameter was renamed to `server`.
 - `key_options` - This parameter was renamed to `options`.
 
-#####`apt::release`
+##### `apt::release`
 - This class was removed. See this [example](examples/release.pp) for how to achieve this functionality.
 
-#####`apt::source`
+##### `apt::source`
 - `include_src` - This parameter was removed. Use `include => { 'src' => <bool> }` instead. ***NOTE*** This now defaults to false.
 - `include_deb` - This parameter was removed. Use `include => { 'deb' => <bool> }` instead.
 - `required_packages` - This parameter was removed. Use package resources for these packages if needed.
@@ -158,35 +210,35 @@ As this is a major rewrite of the module there are a great number of backwards i
 - `key_source` - This parameter was removed. Use `key => { 'source' => <source> }` instead.
 - `trusted_source` - This parameter was renamed to `allow_unsigned`.
 
-#####`apt::unattended_upgrades`
+##### `apt::unattended_upgrades`
 - This class was removed and is being republished under the puppet-community namespace. The git repository is available [here](https://github.com/puppet-community/puppet-unattended_upgrades) and it will be published to the forge [here](https://forge.puppetlabs.com/puppet/unattended_upgrades).
 
-####Changes to default behavior
+#### Changes to default behavior
 - By default purge unmanaged files in 'sources.list', 'sources.list.d', 'preferences', and 'preferences.d'.
 - Changed default for `package_manage` in `apt::ppa` to `false`. Set to `true` in a single PPA if you need the package to be managed.
 - `apt::source` will no longer include the `src` entries by default. 
 - `pin` in `apt::source` now defaults to `undef` instead of `false`
 
-####Features
+#### Features
 - Added the ability to pass hashes of `apt::key`s, `apt::ppa`s, and `apt::setting`s to `apt`.
 - Added 'https' key to `proxy` hash to allow disabling `https_proxy` for the `apt::ppa` environment.
 - Added `apt::setting` define to abstract away configuration.
 - Added the ability to pass hashes to `pin` and `key` in `apt::backports` and `apt::source`.
 
-####Bugfixes
+#### Bugfixes
 - Fixes for strict variables.
 
-##2015-03-17 - Supported Release 1.8.0
-###Summary
+## 2015-03-17 - Supported Release 1.8.0
+### Summary
 
 This is the last planned feature release of the 1.x series of this module. All new features will be evaluated for puppetlabs-apt 2.x.
 
 This release includes many important features, including support for full fingerprints, and fixes issues where `apt_key` was not supporting user/password and `apt_has_updates` was not properly parsing the `apt-check` output.
 
-####Changes to default behavior
+#### Changes to default behavior
 - The apt module will now throw warnings if you don't use full fingerprints for `apt_key`s
 
-####Features
+#### Features
 - Use gpg to check keys to work around https://bugs.launchpad.net/ubuntu/+source/gnupg2/+bug/1409117 (MODULES-1675)
 - Add 'oldstable' to the default update origins for wheezy
 - Add utopic, vivid, and cumulus compatibility
@@ -200,7 +252,7 @@ This release includes many important features, including support for full finger
   - `legacy_origin`
 - Separate `apt::pin` from `apt::backports` to allow pin by release instead of origin
 
-####Bugfixes
+#### Bugfixes
 - Cleanup lint and future parser issues
 - Fix to support username and passwords again for `apt_key` (MODULES-1119)
 - Fix issue where `apt::force` `$install_check` didn't work with non-English locales (MODULES-1231)
@@ -210,12 +262,12 @@ This release includes many important features, including support for full finger
 - Fix inconsistent headers across files (MODULES-1200)
 - Clean up formatting for 50unattended-upgrades.erb
 
-##2014-10-28 - Supported Release 1.7.0
-###Summary
+## 2014-10-28 - Supported Release 1.7.0
+### Summary
 
 This release includes several new features, documentation and test improvements, and a few bug fixes.
 
-####Features
+#### Features
 - Updated unit and acceptance tests
 - Update module to work with Linux Mint
 - Documentation updates
@@ -228,52 +280,52 @@ This release includes several new features, documentation and test improvements,
 - Added `apt_update_last_success` fact
 - Refactored facts for performance improvements
 
-####Bugfixes
+#### Bugfixes
 - Update apt::builddep to require Exec['apt_update'] instead of notifying it
 - Clean up lint errors
 
-##2014-08-20 - Supported Release 1.6.0
-###Summary
+## 2014-08-20 - Supported Release 1.6.0
+### Summary
 
-####Features
+#### Features
 - Allow URL or domain name for key_server parameter
 - Allow custom comment for sources list
 - Enable auto-update for Debian squeeze LTS
 - Add facts showing available updates
 - Test refactoring
 
-####Bugfixes
+#### Bugfixes
 - Allow dashes in URL or domain for key_server parameter
 
-##2014-08-13 - Supported Release 1.5.3
-###Summary
+## 2014-08-13 - Supported Release 1.5.3
+### Summary
 
 This is a bugfix releases.  It addresses a bad regex, failures with unicode
 characters, and issues with the $proxy_host handling in apt::ppa.
 
-####Features
+#### Features
 - Synced files from Modulesync
 
-####Bugfixes
+#### Bugfixes
 - Fix regex to follow APT requirements in apt::pin
 - Fix for unicode characters
 - Fix inconsistent $proxy_host handling in apt and apt::ppa
 - Fix typo in README
 - Fix broken acceptance tests
 
-##2014-07-15 - Supported Release 1.5.2
-###Summary
+## 2014-07-15 - Supported Release 1.5.2
+### Summary
 
 This release merely updates metadata.json so the module can be uninstalled and
 upgraded via the puppet module command.
 
-##2014-07-10 - Supported Release 1.5.1
-###Summary
+## 2014-07-10 - Supported Release 1.5.1
+### Summary
 
 This release has added tests to ensure graceful failure on OSX.
 
-##2014-06-04 - Release 1.5.0
-###Summary
+## 2014-06-04 - Release 1.5.0
+### Summary
 
 This release adds support for Ubuntu 14.04.  It also includes many new features 
 and important bugfixes.  One huge change is that apt::key was replaced with
@@ -282,7 +334,7 @@ your system.
 
 Special thanks to daenney, our intrepid unofficial apt maintainer!
 
-####Features
+#### Features
 - Add support for Ubuntu Trusty!
 - Add apt::hold define
 - Generate valid *.pref files in apt::pin
@@ -292,36 +344,36 @@ Special thanks to daenney, our intrepid unofficial apt maintainer!
 - apt::key rewritten to use apt_key type
 - Add support for update_tries to apt::update
 
-####Bugfixes
+#### Bugfixes
 - Typo fixes
 - Fix unattended upgrades
 - Removed bogus line when using purge_preferences
 - Fix apt::force to upgrade allow packages to be upgraded to the pacakge from the specified release
 
-##2014-03-04 - Supported Release 1.4.2
-###Summary
+## 2014-03-04 - Supported Release 1.4.2
+### Summary
 
 This is a supported release. This release tidies up 1.4.1 and re-enables
 support for Ubuntu 10.04
 
-####Features
+#### Features
 
-####Bugfixes
+#### Bugfixes
 - Fix apt:ppa to include the -y Ubuntu 10.04 requires.
 - Documentation changes.
 - Test fixups.
 
-####Known Bugs
+#### Known Bugs
 
 * No known issues.
 
 
 
-##2014-02-13 1.4.1
-###Summary
+## 2014-02-13 1.4.1
+### Summary
 This is a bugfix release.
 
-####Bugfixes
+#### Bugfixes
 - Fix apt::force unable to upgrade packages from releases other than its original
 - Removed a few refeneces to aptitude instead of apt-get for portability
 - Removed call to getparam() due to stdlib dependency
@@ -330,21 +382,21 @@ This is a bugfix release.
 - Use root to exec in apt::ppa
 - Updated tests and converted acceptance tests to beaker
 
-##2013-10-08 - Release 1.4.0
+## 2013-10-08 - Release 1.4.0
 
-###Summary
+### Summary
 
 Minor bugfix and allow the timeout to be adjusted.
 
-####Features
+#### Features
 - Add an `updates_timeout` to apt::params
 
-####Bugfixes
+#### Bugfixes
 - Ensure apt::ppa can read a ppa removed by hand.
 
 
-##2013-10-08 - Release 1.3.0
-###Summary
+## 2013-10-08 - Release 1.3.0
+### Summary
 
 This major feature in this release is the new apt::unattended_upgrades class,
 allowing you to handle Ubuntu's unattended feature.  This allows you to select
@@ -354,21 +406,21 @@ involvement.
 In addition we extend our Wheezy support, add proxy support to apt:ppa and do
 various cleanups and tweaks.
 
-####Features
+#### Features
 - Add apt::unattended_upgrades support for Ubuntu.
 - Add wheezy backports support.
 - Use the geoDNS http.debian.net instead of the main debian ftp server.
 - Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command.
 - Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt).
 
-####Bugfixes
+#### Bugfixes
 - Fix regsubst() calls to quote single letters (for future parser).
 - Fix lint warnings and other misc cleanup.
 
 
-##2013-07-03 - Release 1.2.0
+## 2013-07-03 - Release 1.2.0
 
-####Features
+#### Features
 - Add geppetto `.project` natures
 - Add GH auto-release
 - Add `apt::key::key_options` parameter
@@ -380,14 +432,14 @@ various cleanups and tweaks.
   - `apt::pin::label`
 - Add source architecture support to `apt::source::architecture`
 
-####Bugfixes
+#### Bugfixes
 - Use apt-get instead of aptitude in apt::force
 - Update default backports location
 - Add dependency for required packages before apt-get update
 
 
-##2013-06-02 - Release 1.1.1
-###Summary
+## 2013-06-02 - Release 1.1.1
+### Summary
 
 This is a bug fix release that resolves a number of issues:
 
@@ -421,14 +473,14 @@ Thanks to all the community contributors below that made this patch possible.
 
 
 ## Release 1.1.0
-###Summary
+### Summary
 
 This release includes Ubuntu 12.10 (Quantal) support for PPAs.
 
 ---
 
-##2012-05-25 - Puppet Labs <info@puppetlabs.com> - Release 0.0.4
-###Summary
+## 2012-05-25 - Puppet Labs <info@puppetlabs.com> - Release 0.0.4
+### Summary
 
  * Fix ppa list filename when there is a period in the PPA name
  * Add .pref extension to apt preferences files
@@ -436,8 +488,8 @@ This release includes Ubuntu 12.10 (Quantal) support for PPAs.
  * Extend pin support
 
 
-##2012-05-04 - Puppet Labs <info@puppetlabs.com> - Release 0.0.3
-###Summary
+## 2012-05-04 - Puppet Labs <info@puppetlabs.com> - Release 0.0.3
+### Summary
  
  * only invoke apt-get update once
  * only install python-software-properties if a ppa is added
@@ -450,8 +502,8 @@ This release includes Ubuntu 12.10 (Quantal) support for PPAs.
  * add support to pin release
 
 
-##2012-03-26 - Puppet Labs <info@puppetlabs.com> - Release 0.0.2
-###Summary
+## 2012-03-26 - Puppet Labs <info@puppetlabs.com> - Release 0.0.2
+### Summary
 
 * 41cedbb (#13261) Add real examples to smoke tests.
 * d159a78 (#13261) Add key.pp smoke test
@@ -465,8 +517,8 @@ This release includes Ubuntu 12.10 (Quantal) support for PPAs.
 * b9607a4 Convert apt::key to use anchors
 
 
-##2012-03-07 - Puppet Labs <info@puppetlabs.com> - Release 0.0.1
-###Summary
+## 2012-03-07 - Puppet Labs <info@puppetlabs.com> - Release 0.0.1
+### Summary
 
 * d4fec56 Modify apt::source release parameter test
 * 1132a07 (#12917) Add contributors to README
index 990edba7e70c856cb84c64affdafa9b4f98aa110..1a9fb3a5cd686bd5f281ea3c2eaec843d65b25cd 100644 (file)
@@ -1,63 +1,75 @@
-Checklist (and a short version for the impatient)
-=================================================
+# Contributing to Puppet modules
 
-  * Commits:
+So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing
+that very thing while setting expectations around code quality as well as a few tips for making the
+process as easy as possible. 
 
-    - Make commits of logical units.
+### Table of Contents
 
-    - Check for unnecessary whitespace with "git diff --check" before
-      committing.
+1. [Getting Started](#getting-started)
+1. [Commit Checklist](#commit-checklist)
+1. [Submission](#submission)
+1. [More about commits](#more-about-commits)
+1. [Testing](#testing)
+    - [Running Tests](#running-tests)
+    - [Writing Tests](#writing-tests)
+1. [Get Help](#get-help)
 
-    - Commit using Unix line endings (check the settings around "crlf" in
-      git-config(1)).
+## Getting Started
 
-    - Do not check in commented out code or unneeded files.
+- Fork the module repository on GitHub and clone to your workspace
 
-    - The first line of the commit message should be a short
-      description (50 characters is the soft limit, excluding ticket
-      number(s)), and should skip the full stop.
+- Make your changes!
 
-    - Associate the issue in the message. The first line should include
-      the issue number in the form "(#XXXX) Rest of message".
+## Commit Checklist
 
-    - The body should provide a meaningful commit message, which:
+### The Basics
 
-      - uses the imperative, present tense: "change", not "changed" or
-        "changes".
+- [x] my commit is a single logical unit of work
 
-      - includes motivation for the change, and contrasts its
-        implementation with the previous behavior.
+- [x] I have checked for unnecessary whitespace with "git diff --check" 
 
-    - Make sure that you have tests for the bug you are fixing, or
-      feature you are adding.
+- [x] my commit does not include commented out code or unneeded files
 
-    - Make sure the test suites passes after your commit:
-      `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below
+### The Content
 
-    - When introducing a new feature, make sure it is properly
-      documented in the README.md
+- [x] my commit includes tests for the bug I fixed or feature I added
 
-  * Submission:
+- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
+    
+- [x] my code passes existing test suites
 
-    * Pre-requisites:
+### The Commit Message
 
-      - Make sure you have a [GitHub account](https://github.com/join)
+- [x] the first line of my commit message includes:
 
-      - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
+  - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" 
+  
+  - [x] a short description (50 characters is the soft limit, excluding ticket number(s))
 
-    * Preferred method:
+- [x] the body of my commit message:
 
-      - Fork the repository on GitHub.
+  - [x] is meaningful
 
-      - Push your changes to a topic branch in your fork of the
-        repository. (the format ticket/1234-short_description_of_change is
-        usually preferred for this project).
+  - [x] uses the imperative, present tense: "change", not "changed" or "changes"
 
-      - Submit a pull request to the repository in the puppetlabs
-        organization.
+  - [x] includes motivation for the change, and contrasts its implementation with the previous behavior
 
-The long version
-================
+## Submission
+
+### Pre-requisites
+
+- Make sure you have a [GitHub account](https://github.com/join)
+
+- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
+
+### Push and PR
+
+- Push your changes to your fork
+
+- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
+
+## More about commits 
 
   1.  Make separate commits for logically separate changes.
 
@@ -104,37 +116,32 @@ The long version
       GitHub has some pretty good
       [general documentation](http://help.github.com/) on using
       their site.  They also have documentation on
-      [creating pull requests](http://help.github.com/send-pull-requests/).
+      [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
 
       In general, after pushing your topic branch up to your
       repository on GitHub, you can switch to the branch in the
       GitHub UI and click "Pull Request" towards the top of the page
       in order to open a pull request.
 
+  3.  Update the related JIRA issue.
 
-  3.  Update the related GitHub issue.
-
-      If there is a GitHub issue associated with the change you
+      If there is a JIRA issue associated with the change you
       submitted, then you should update the ticket to include the
       location of your branch, along with any other commentary you
       may wish to make.
 
-Testing
-=======
+# Testing
 
-Getting Started
----------------
+## Getting Started
 
-Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby
-package manager such as [bundler](http://bundler.io/) what Ruby packages,
+Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
 or Gems, are required to build, develop, and test this software.
 
-Please make sure you have [bundler installed](http://bundler.io/#getting-started)
-on your system, then use it to install all dependencies needed for this project,
-by running
+Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to 
+install all dependencies needed for this project in the project root by running
 
 ```shell
-% bundle install
+% bundle install --path .bundle/gems
 Fetching gem metadata from https://rubygems.org/........
 Fetching gem metadata from https://rubygems.org/..
 Using rake (10.1.0)
@@ -148,7 +155,7 @@ Your bundle is complete!
 Use `bundle show [gemname]` to see where a bundled gem is installed.
 ```
 
-NOTE some systems may require you to run this command with sudo.
+NOTE: some systems may require you to run this command with sudo.
 
 If you already have those gems installed, make sure they are up-to-date:
 
@@ -156,26 +163,27 @@ If you already have those gems installed, make sure they are up-to-date:
 % bundle update
 ```
 
-With all dependencies in place and up-to-date we can now run the tests:
+## Running Tests
+
+With all dependencies in place and up-to-date, run the tests:
+
+### Unit Tests
 
 ```shell
 % bundle exec rake spec
 ```
 
-This will execute all the [rspec tests](http://rspec-puppet.com/) tests
-under [spec/defines](./spec/defines), [spec/classes](./spec/classes),
-and so on. rspec tests may have the same kind of dependencies as the
-module they are testing. While the module defines in its [Modulefile](./Modulefile),
+This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. 
+rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
 rspec tests define them in [.fixtures.yml](./fixtures.yml).
 
-Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker)
-tests. These tests spin up a virtual machine under
-[VirtualBox](https://www.virtualbox.org/)) with, controlling it with
-[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test
-scenarios. In order to run these, you will need both of those tools
-installed on your system.
+### Acceptance Tests
+
+Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
+[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
+scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.
 
-You can run them by issuing the following command
+Run the tests by issuing the following command
 
 ```shell
 % bundle exec rake spec_clean
@@ -183,35 +191,81 @@ You can run them by issuing the following command
 ```
 
 This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
-install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
+install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
 and then run all the tests under [spec/acceptance](./spec/acceptance).
 
-Writing Tests
--------------
+## Writing Tests
+
+### Unit Tests
 
-XXX getting started writing tests.
+When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a 
+catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] 
+but here's a tiny sample:
 
-If you have commit access to the repository
-===========================================
+Sample manifest:
 
-Even if you have commit access to the repository, you will still need to
-go through the process above, and have someone else review and merge
-in your changes.  The rule is that all changes must be reviewed by a
-developer on the project (that did not write the code) to ensure that
-all changes go through a code review process.
+```puppet
+file { "a test file":
+  ensure => present,
+  path   => "/etc/sample",
+}
+```
+
+Sample test:
 
-Having someone other than the author of the topic branch recorded as
-performing the merge is the record that they performed the code
-review.
+```ruby
+it 'does a thing' do
+  expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
+end
+```
 
+### Acceptance Tests
+
+Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
+twice to check for idempotency or errors, then run expectations.
+
+```ruby
+it 'does an end-to-end thing' do
+  pp = <<-EOF
+    file { 'a test file': 
+      ensure  => present,
+      path    => "/etc/sample",
+      content => "test string",
+    }
+    
+  apply_manifest(pp, :catch_failures => true)
+  apply_manifest(pp, :catch_changes => true)
+  
+end
+
+describe file("/etc/sample") do
+  it { is_expected.to contain "test string" }
+end
 
-Additional Resources
-====================
+```
 
-* [Getting additional help](http://puppet.com/community/get-help)
+# If you have commit access to the repository
 
-* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
+Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
+in your changes.  The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
+all changes go through a code review process.**
 
-* [General GitHub documentation](http://help.github.com/)
+The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
 
+# Get Help
+
+### On the web
+* [Puppet help messageboard](http://puppet.com/community/get-help)
+* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
+* [General GitHub documentation](http://help.github.com/)
 * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
+
+### On chat
+* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
+* IRC (freenode) #puppet-dev, #voxpupuli
+
+
+[rspec-puppet]: http://rspec-puppet.com/
+[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
+[beaker]: https://github.com/puppetlabs/beaker
+[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
diff --git a/Gemfile b/Gemfile
index 5d863251d66604c2b1327f1e0fb6b420dadb6076..a9f0161c79e6ba92b7a4f6f7a52750339be2299e 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -29,38 +29,28 @@ end
 
 # Used for gem conditionals
 supports_windows = false
+ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
+minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}"
 
 group :development do
-  gem 'puppet-lint',                        :require => false
-  gem 'metadata-json-lint',                 :require => false, :platforms => 'ruby'
-  gem 'puppet_facts',                       :require => false
-  gem 'puppet-blacksmith', '>= 3.4.0',      :require => false, :platforms => 'ruby'
-  gem 'puppetlabs_spec_helper', '>= 1.2.1', :require => false
-  gem 'rspec-puppet', '>= 2.3.2',           :require => false
-  gem 'rspec-puppet-facts',                 :require => false, :platforms => 'ruby'
-  gem 'mocha', '< 1.2.0',                   :require => false
-  gem 'simplecov',                          :require => false, :platforms => 'ruby'
-  gem 'parallel_tests', '< 2.10.0',         :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
-  gem 'parallel_tests',                     :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
-  gem 'rubocop', '0.41.2',                  :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
-  gem 'rubocop',                            :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
-  gem 'rubocop-rspec', '~> 1.6',            :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')
-  gem 'pry',                                :require => false
-  gem 'json_pure', '<= 2.0.1',              :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
-  gem 'fast_gettext', '1.1.0',              :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
-  gem 'fast_gettext',                       :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
-  gem 'rainbow', '< 2.2.0',                 :require => false
+  gem "puppet-module-posix-default-r#{minor_version}",    :require => false, :platforms => "ruby"
+  gem "puppet-module-win-default-r#{minor_version}",      :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
+  gem "puppet-module-posix-dev-r#{minor_version}",        :require => false, :platforms => "ruby"
+  gem "puppet-module-win-dev-r#{minor_version}", '0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
+  gem "json_pure", '<= 2.0.1',                            :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
+  gem "fast_gettext", '1.1.0',                            :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
+  gem "fast_gettext",                                     :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
 end
 
 group :system_tests do
-  gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '>= 3')                  
-  gem 'beaker-pe',                                                               :require => false
-  gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'])                
-  gem 'beaker-puppet_install_helper',                                            :require => false
-  gem 'beaker-module_install_helper',                                            :require => false
-  gem 'master_manipulator',                                                      :require => false
-  gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
-  gem 'beaker-abs', *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')        
+  gem "puppet-module-posix-system-r#{minor_version}",                            :require => false, :platforms => "ruby"
+  gem "puppet-module-win-system-r#{minor_version}",                              :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
+  gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3')                  
+  gem "beaker-pe",                                                               :require => false
+  gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])                
+  gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
+  gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')        
+  gem "puppet-blacksmith", '~> 3.4',                                             :require => false
 end
 
 gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
diff --git a/NOTICE b/NOTICE
index 8da18e1c7f296f8a8ecf2f55d2bfec644041d571..209695b98f38f30caa2185e9e8bb51dea9032a8b 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1,15 +1,12 @@
-apt puppet module
-
-Copyright (C) 2014-2016 Puppet Labs, Inc.
-
-Puppet Labs can be contacted at: info@puppetlabs.com
+Puppet Module - puppetlabs-apt
 
+Copyright 2017 Puppet, Inc.
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0
+    http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
index 423c6c69fed29c3013d12380d1a52a28108beb7a..9c2ded4b12abc33c40ae8ce23378e85f7512e525 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ include apt
 
 **Warning:** Using short key IDs presents a serious security issue, potentially leaving you open to collision attacks. We recommend you always use full fingerprints to identify your GPG keys. This module allows short keys, but issues a security warning if you use them.
 
-Declare the `apt::key` class:
+Declare the `apt::key` defined type:
 
 ```puppet
 apt::key { 'puppetlabs':
@@ -91,6 +91,15 @@ class { 'apt':
   },
 }
 ```
+When `Exec['apt_update']` is triggered, it will generate a `Notice` message. Because the default [logging level for agents](https://docs.puppet.com/puppet/latest/configuration.html#loglevel) is `notice`, this will cause the repository update to appear in logs and agent reports. Some tools, such as [The Foreman](https://www.theforeman.org), report the update notice as a significant change. By setting the [loglevel](https://docs.puppet.com/puppet/latest/metaparameter.html#loglevel) metaparameter for `Exec['apt_update']` above the agent logging level, one can eliminate these updates from reports:
+```puppet
+class { 'apt':
+  update => {
+    frequency => 'daily',
+    loglevel  => 'debug',
+  },
+}
+```
 
 ### Pin a specific release
 
@@ -150,7 +159,7 @@ apt::source { 'puppetlabs':
     'id'     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
     'server' => 'pgp.mit.edu',
   },
-},
+}
 ```
 
 ### Configure Apt from Hiera
@@ -192,21 +201,21 @@ apt::source { "archive.ubuntu.com-${lsbdistcodename}":
   key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
   repos    => 'main universe multiverse restricted',
 }
+
 apt::source { "archive.ubuntu.com-${lsbdistcodename}-security":
   location => 'http://archive.ubuntu.com/ubuntu',
   key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
   repos    => 'main universe multiverse restricted',
   release  => "${lsbdistcodename}-security"
 }
+
 apt::source { "archive.ubuntu.com-${lsbdistcodename}-updates":
   location => 'http://archive.ubuntu.com/ubuntu',
   key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
   repos    => 'main universe multiverse restricted',
   release  => "${lsbdistcodename}-updates"
 }
+
 apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports":
  location => 'http://archive.ubuntu.com/ubuntu',
  key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
@@ -270,7 +279,7 @@ Main class, includes all other classes.
 
   * 'host': Specifies a proxy host to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a hostname. Default: undef.
 
-  * 'port': Specifies a proxy port to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a port number. Default: '8080'.
+  * 'port': Specifies a proxy port to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: an integer containing a port number. Default: 8080.
 
   * 'https': Specifies whether to enable https proxies. Valid options: 'true' and 'false'. Default: 'false'.
 
@@ -313,8 +322,7 @@ Manages backports.
 
 * `location`: Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Defaults:
 
-  * Debian (squeeze): 'http://httpredir.debian.org/debian-backports'
-  * Debian (other): 'http://httpredir.debian.org/debian'
+  * Debian: 'http://deb.debian.org/debian'
   * Ubuntu: 'http://archive.ubuntu.com/ubuntu'
 
 * `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'.
@@ -360,16 +368,6 @@ The `apt::key` defined type makes use of the `apt_key` type, but includes extra
 
 * `server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'.
 
-* `key`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: undef. **Note** This parameter is deprecated and will be removed in a future release.
-
-* `key_content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release.
-
-* `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release.
-
-* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. **Note** This parameter is deprecated and will be removed in a future release.
-
-* `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release.
-
 #### Defined Type: `apt::pin`
 
 Manages Apt pins. Does not trigger an `apt-get update` run.
@@ -473,20 +471,6 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`.
 
   * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'.
 
-* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `required_packages`: Installs packages required for this Apt source via an exec. Default: 'false'. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `key_content`: Specifies the content to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `key_server`: Specifies the server to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `key_source`: Specifies the source to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module.
-
-* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module.
-
 * `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'.
 
 #### Type: `apt_key`
index e880fdf29841b264b01335b709caf30f78693d15..e101dd79a477aae25ebf99995f080f15a76d95a3 100644 (file)
@@ -2,7 +2,7 @@ apt_package_updates = nil
 Facter.add("apt_has_updates") do
   confine :osfamily => 'Debian'
   if File.executable?("/usr/bin/apt-get")
-    apt_get_result = Facter::Util::Resolution.exec('/usr/bin/apt-get -s upgrade 2>&1')
+    apt_get_result = Facter::Util::Resolution.exec('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1')
     if not apt_get_result.nil?
       apt_package_updates = [[], []]
       apt_get_result.each_line do |line|
@@ -42,6 +42,17 @@ Facter.add("apt_package_updates") do
   end
 end
 
+Facter.add("apt_package_security_updates") do
+  confine :apt_has_updates => true
+  setcode do
+    if Facter.version < '2.0.0'
+      apt_package_updates[1].join(',')
+    else
+      apt_package_updates[1]
+    end
+  end
+end
+
 Facter.add("apt_updates") do
   confine :apt_has_updates => true
   setcode do
index d7e85dafaf5a1e6ab762153f137394a49cc52d47..3f95c3cc96af9c68f40234d6f07a9a3072be5173 100644 (file)
@@ -26,15 +26,25 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       key_output = apt_key(cli_args)
     end
 
-    pub_line, fpr_line = nil
+    pub_line, sub_line, fpr_line = nil
 
     key_array = key_output.split("\n").collect do |line|
       if line.start_with?('pub')
           pub_line = line
+          # reset fpr_line, to skip any previous subkeys which were collected
+          fpr_line = nil
+          sub_line = nil
+      elsif line.start_with?('sub')
+          sub_line = line
       elsif line.start_with?('fpr')
           fpr_line = line
       end
 
+      if (sub_line and fpr_line)
+        sub_line, fpr_line = nil
+        next
+      end
+
       next unless (pub_line and fpr_line)
 
       line_hash = key_line_hash(pub_line, fpr_line)
@@ -127,9 +137,15 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       f
     else
       begin
-        user_pass = parsedValue.userinfo.nil? ? nil : parsedValue.userinfo.split(':')
-        parsedValue.userinfo = ''
-        key = open(parsedValue, :http_basic_authentication => user_pass).read
+        # Only send basic auth if URL contains userinfo
+        # Some webservers (e.g. Amazon S3) return code 400 if empty basic auth is sent
+        if parsedValue.userinfo.nil?
+          key = parsedValue.read
+        else
+          user_pass = parsedValue.userinfo.split(':')
+          parsedValue.userinfo = ''
+          key = open(parsedValue, :http_basic_authentication => user_pass).read
+        end
       rescue OpenURI::HTTPError, Net::FTPPermError => e
         fail("#{e.message} for #{resource[:source]}")
       rescue SocketError
diff --git a/locales/config.yaml b/locales/config.yaml
new file mode 100644 (file)
index 0000000..3f64263
--- /dev/null
@@ -0,0 +1,26 @@
+---
+# This is the project-specific configuration file for setting up
+# fast_gettext for your project.
+gettext:
+  # This is used for the name of the .pot and .po files; they will be
+  # called <project_name>.pot?
+  project_name: puppetlabs-apt
+  # This is used in comments in the .pot and .po files to indicate what
+  # project the files belong to and should bea little more desctiptive than
+  # <project_name>
+  package_name: puppetlabs-apt
+  # The locale that the default messages in the .pot file are in
+  default_locale: en
+  # The email used for sending bug reports.
+  bugs_address: docs@puppet.com
+  # The holder of the copyright.
+  copyright_holder: Puppet, Inc.
+  # This determines which comments in code should be eligible for translation.
+  # Any comments that start with this string will be externalized. (Leave
+  # empty to include all.)
+  comments_tag: TRANSLATOR
+  # Patterns for +Dir.glob+ used to find all files that might contain
+  # translatable content, relative to the project root directory
+  source_files:
+      - './lib/**/*.rb'
+  
index f7e85f59ed9744fdaaaa8ce7b46d9b788e23ce60..4faad6157a7f31664555471071c211e177e56ce2 100644 (file)
@@ -1,34 +1,28 @@
 class apt::backports (
-  $location = undef,
-  $release  = undef,
-  $repos    = undef,
-  $key      = undef,
-  $pin      = 200,
+  Optional[String] $location                    = undef,
+  Optional[String] $release                     = undef,
+  Optional[String] $repos                       = undef,
+  Optional[Variant[String, Hash]] $key          = undef,
+  Optional[Variant[Integer, String, Hash]] $pin = 200,
 ){
   if $location {
-    validate_string($location)
     $_location = $location
   }
   if $release {
-    validate_string($release)
     $_release = $release
   }
   if $repos {
-    validate_string($repos)
     $_repos = $repos
   }
   if $key {
-    unless is_hash($key) {
-      validate_string($key)
-    }
     $_key = $key
   }
-  if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') {
+  if ($facts['lsbdistid'] == 'Debian' or $facts['lsbdistid'] == 'Ubuntu') {
     unless $location {
       $_location = $::apt::backports['location']
     }
     unless $release {
-      $_release = "${::apt::xfacts['lsbdistcodename']}-backports"
+      $_release = "${facts['lsbdistcodename']}-backports"
     }
     unless $repos {
       $_repos = $::apt::backports['repos']
index 8cd9c64e7841064ffa5c92e451daba8a48dd3090..eea06861d9e3793e807a9e77d5388d0897941d3c 100644 (file)
@@ -1,8 +1,8 @@
 define apt::conf (
-  $content       = undef,
-  $ensure        = present,
-  $priority      = 50,
-  $notify_update = undef,
+  Optional[String] $content          = undef,
+  Enum['present', 'absent'] $ensure  = present,
+  Variant[String, Integer] $priority = 50,
+  Optional[Boolean] $notify_update   = undef,
 ) {
 
   unless $ensure == 'absent' {
@@ -11,10 +11,11 @@ define apt::conf (
     }
   }
 
+  $confheadertmp = epp('apt/_conf_header.epp')
   apt::setting { "conf-${name}":
     ensure        => $ensure,
     priority      => $priority,
-    content       => template('apt/_conf_header.erb', 'apt/conf.erb'),
+    content       => "${confheadertmp}${content}",
     notify_update => $notify_update,
   }
 }
index 5664edeed5220192b10bc1b0974e8ab98f557d78..44e66ce51ff2dd00980603ae05423c11d092cae3 100644 (file)
@@ -3,82 +3,92 @@
 # Manage APT (Advanced Packaging Tool)
 #
 class apt (
-  $confs    = {},
-  $update   = {},
-  $purge    = {},
-  $proxy    = {},
-  $sources  = {},
-  $keys     = {},
-  $ppas     = {},
-  $pins     = {},
-  $settings = {},
-) inherits ::apt::params {
+  Hash $update_defaults         = $apt::params::update_defaults,
+  Hash $purge_defaults          = $apt::params::purge_defaults,
+  Hash $proxy_defaults          = $apt::params::proxy_defaults,
+  Hash $include_defaults        = $apt::params::include_defaults,
+  String $provider              = $apt::params::provider,
+  String $keyserver             = $apt::params::keyserver,
+  Optional[String] $ppa_options = $apt::params::ppa_options,
+  Optional[String] $ppa_package = $apt::params::ppa_package,
+  Optional[Hash] $backports     = $apt::params::backports,
+  Hash $confs                   = $apt::params::confs,
+  Hash $update                  = $apt::params::update,
+  Hash $purge                   = $apt::params::purge,
+  Hash $proxy                   = $apt::params::proxy,
+  Hash $sources                 = $apt::params::sources,
+  Hash $keys                    = $apt::params::keys,
+  Hash $ppas                    = $apt::params::ppas,
+  Hash $pins                    = $apt::params::pins,
+  Hash $settings                = $apt::params::settings,
+  String $root                  = $apt::params::root,
+  String $sources_list          = $apt::params::sources_list,
+  String $sources_list_d        = $apt::params::sources_list_d,
+  String $conf_d                = $apt::params::conf_d,
+  String $preferences           = $apt::params::preferences,
+  String $preferences_d         = $apt::params::preferences_d,
+  Hash $config_files            = $apt::params::config_files,
+  Hash $source_key_defaults     = $apt::params::source_key_defaults
+) inherits apt::params {
+
+  if $facts['osfamily'] != 'Debian' {
+    fail('This module only works on Debian or derivatives like Ubuntu')
+  }
 
   $frequency_options = ['always','daily','weekly','reluctantly']
-  validate_hash($update)
+
   if $update['frequency'] {
     validate_re($update['frequency'], $frequency_options)
   }
   if $update['timeout'] {
-    unless is_integer($update['timeout']) {
-      fail('timeout value for update must be an integer')
-    }
+    assert_type(Integer, $update['timeout'])
   }
   if $update['tries'] {
-    unless is_integer($update['tries']) {
-      fail('tries value for update must be an integer')
-    }
+    assert_type(Integer, $update['tries'])
   }
 
   $_update = merge($::apt::update_defaults, $update)
   include ::apt::update
 
-  validate_hash($purge)
   if $purge['sources.list'] {
-    validate_bool($purge['sources.list'])
+    assert_type(Boolean, $purge['sources.list'])
   }
   if $purge['sources.list.d'] {
-    validate_bool($purge['sources.list.d'])
+    assert_type(Boolean, $purge['sources.list.d'])
   }
   if $purge['preferences'] {
-    validate_bool($purge['preferences'])
+    assert_type(Boolean, $purge['preferences'])
   }
   if $purge['preferences.d'] {
-    validate_bool($purge['preferences.d'])
+    assert_type(Boolean, $purge['preferences.d'])
   }
 
   $_purge = merge($::apt::purge_defaults, $purge)
 
-  validate_hash($proxy)
   if $proxy['ensure'] {
     validate_re($proxy['ensure'], ['file', 'present', 'absent'])
   }
   if $proxy['host'] {
-    validate_string($proxy['host'])
+    assert_type(String, $proxy['host'])
   }
   if $proxy['port'] {
-    unless is_integer($proxy['port']) {
-      fail('$proxy port must be an integer')
-    }
+    assert_type(Integer, $proxy['port'])
   }
-  if $proxy['https'] {
-    validate_bool($proxy['https'])
+  if $proxy['https']{
+    assert_type(Boolean, $proxy['https'])
   }
 
   $_proxy = merge($apt::proxy_defaults, $proxy)
 
-  validate_hash($confs)
-  validate_hash($sources)
-  validate_hash($keys)
-  validate_hash($settings)
-  validate_hash($ppas)
-  validate_hash($pins)
+  $confheadertmp = epp('apt/_conf_header.epp')
+  $proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
+  $updatestamptmp = epp('apt/15update-stamp.epp')
 
   if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
     apt::setting { 'conf-proxy':
       ensure   => $_proxy['ensure'],
       priority => '01',
-      content  => template('apt/_conf_header.erb', 'apt/proxy.erb'),
+      content  => "${confheadertmp}${proxytmp}",
     }
   }
 
@@ -100,7 +110,7 @@ class apt (
 
   apt::setting { 'conf-update-stamp':
     priority => 15,
-    content  => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'),
+    content  => "${confheadertmp}${updatestamptmp}",
   }
 
   file { 'sources.list':
@@ -168,4 +178,19 @@ class apt (
   if $pins {
     create_resources('apt::pin', $pins)
   }
+
+  # required for adding GPG keys on Debian 9 (and derivatives)
+  case $facts['os']['name'] {
+    'Debian': {
+      if versioncmp($facts['os']['release']['full'], '9.0') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    'Ubuntu': {
+      if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+        ensure_packages(['dirmngr'])
+      }
+    }
+    default: { }
+  }
 }
index 148a751de60e1c419280359f4a7e3ca36089b0cb..8f9d66bcc9a1bf2b45742fec5007a9a849a98f31 100644 (file)
 # == Define: apt::key
 define apt::key (
-  $id          = $title,
-  $ensure      = present,
-  $content     = undef,
-  $source      = undef,
-  $server      = $::apt::keyserver,
-  $options     = undef,
-  $key         = undef,
-  $key_content = undef,
-  $key_source  = undef,
-  $key_server  = undef,
-  $key_options = undef,
-) {
+    String $id                           = $title,
+    Enum['present', 'absent'] $ensure    = present,
+    Optional[String] $content            = undef,
+    Optional[String] $source             = undef,
+    String $server                       = $::apt::keyserver,
+    Optional[String] $options            = undef,
+    ) {
 
-  if $key != undef {
-    deprecation('apt $key', '$key is deprecated and will be removed in the next major release. Please use $id instead.')
-    $_id = $key
-  } else {
-    $_id = $id
-  }
-
-  if $key_content != undef {
-    deprecation('apt $key_content', '$key_content is deprecated and will be removed in the next major release. Please use $content instead.')
-    $_content = $key_content
-  } else {
-    $_content = $content
-  }
-
-  if $key_source != undef {
-    deprecation('apt $key_source', '$key_source is deprecated and will be removed in the next major release. Please use $source instead.')
-    $_source = $key_source
-  } else {
-    $_source = $source
-  }
-
-  if $key_server != undef {
-    deprecation('apt $key_server', '$key_server is deprecated and will be removed in the next major release. Please use $server instead.')
-    $_server = $key_server
-  } else {
-    $_server = $server
-  }
+  validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
 
-  if $key_options != undef {
-    deprecation('apt $key_options', '$key_options is deprecated and will be removed in the next major release. Please use $options instead.')
-    $_options = $key_options
-  } else {
-    $_options = $options
+  if $source {
+    validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
   }
 
-  validate_re($_id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
-  validate_re($ensure, ['\A(absent|present)\Z',])
-
-  if $_content {
-    validate_string($_content)
-  }
-
-  if $_source {
-    validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
-  }
-
-  if $_server {
-    validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
-  }
-
-  if $_options {
-    validate_string($_options)
+  if $server {
+    validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
   }
 
   case $ensure {
     present: {
-      if defined(Anchor["apt_key ${_id} absent"]){
-        fail("key with id ${_id} already ensured as absent")
+      if defined(Anchor["apt_key ${id} absent"]){
+        fail("key with id ${id} already ensured as absent")
       }
 
-      if !defined(Anchor["apt_key ${_id} present"]) {
+      if !defined(Anchor["apt_key ${id} present"]) {
         apt_key { $title:
           ensure  => $ensure,
-          id      => $_id,
-          source  => $_source,
-          content => $_content,
-          server  => $_server,
-          options => $_options,
-        } ->
-        anchor { "apt_key ${_id} present": }
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
+        } -> anchor { "apt_key ${id} present": }
+
+        case $facts['os']['name'] {
+          'Debian': {
+            if versioncmp($facts['os']['release']['full'], '9.0') >= 0 {
+              Apt::Key<| title == $title |> {
+                require => Package['dirmngr']
+              }
+            }
+          }
+          'Ubuntu': {
+            if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
+              Apt::Key<| title == $title |> {
+                require => Package['dirmngr']
+              }
+            }
+          }
+          default: { }
+        }
       }
     }
 
     absent: {
-      if defined(Anchor["apt_key ${_id} present"]){
-        fail("key with id ${_id} already ensured as present")
+      if defined(Anchor["apt_key ${id} present"]){
+        fail("key with id ${id} already ensured as present")
       }
 
-      if !defined(Anchor["apt_key ${_id} absent"]){
+      if !defined(Anchor["apt_key ${id} absent"]){
         apt_key { $title:
           ensure  => $ensure,
-          id      => $_id,
-          source  => $_source,
-          content => $_content,
-          server  => $_server,
-          options => $_options,
-        } ->
-        anchor { "apt_key ${_id} absent": }
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
+        } -> anchor { "apt_key ${id} absent": }
       }
     }
 
index ea1087e7a93655e371cb99c1d039a0f64c5016ef..8126c02be5ccb487776ce3d28071bcf2afa9d563 100644 (file)
@@ -4,32 +4,6 @@ class apt::params {
     fail('This module only works on Debian or derivatives like Ubuntu')
   }
 
-  # 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 $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 {
-    $xfacts = {
-      'lsbdistcodename'     => $::lsbdistcodename,
-      'lsbdistrelease'      => $::lsbdistrelease,
-      'lsbdistid'           => $::lsbdistid,
-    }
-  } else {
-    # Strict variables facts lookup compatibility
-    $xfacts = {
-      'lsbdistcodename' => defined('$lsbdistcodename') ? {
-        true    => $::lsbdistcodename,
-        default => undef,
-      },
-      'lsbdistrelease' => defined('$lsbdistrelease') ? {
-        true    => $::lsbdistrelease,
-        default => undef,
-      },
-      'lsbdistid' => defined('$lsbdistid') ? {
-        true    => $::lsbdistid,
-        default => undef,
-      },
-    }
-  }
-
   $root           = '/etc/apt'
   $provider       = '/usr/bin/apt-get'
   $sources_list   = "${root}/sources.list"
@@ -38,6 +12,15 @@ class apt::params {
   $preferences    = "${root}/preferences"
   $preferences_d  = "${root}/preferences.d"
   $keyserver      = 'keyserver.ubuntu.com'
+  $confs          = {}
+  $update         = {}
+  $purge          = {}
+  $proxy          = {}
+  $sources        = {}
+  $keys           = {}
+  $ppas           = {}
+  $pins           = {}
+  $settings       = {}
 
   $config_files = {
     'conf'   => {
@@ -56,6 +39,7 @@ class apt::params {
 
   $update_defaults = {
     'frequency' => 'reluctantly',
+    'loglevel'  => undef,
     'timeout'   => undef,
     'tries'     => undef,
   }
@@ -86,19 +70,12 @@ class apt::params {
     'src' => false,
   }
 
-  case $xfacts['lsbdistid'] {
-    'debian': {
-      case $xfacts['lsbdistcodename'] {
-        'squeeze': {
-          $backports = {
-            'location' => 'http://httpredir.debian.org/debian-backports',
-            'key'      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-            'repos'    => 'main contrib non-free',
-          }
-        }
+  case $facts['os']['name']{
+    'Debian': {
+      case $facts['os']['release']['full'] {
         default: {
           $backports = {
-            'location' => 'http://httpredir.debian.org/debian',
+            'location' => 'http://deb.debian.org/debian',
             'key'      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
             'repos'    => 'main contrib non-free',
           }
@@ -109,29 +86,34 @@ class apt::params {
       $ppa_package = undef
 
     }
-    'ubuntu': {
+    'Ubuntu': {
       $backports = {
         'location' => 'http://archive.ubuntu.com/ubuntu',
         'key'      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
         'repos'    => 'main universe multiverse restricted',
       }
 
-      if $xfacts['lsbdistcodename'] == 'lucid' {
+      case $facts['os']['release']['full'] {
+        '10.04': {
           $ppa_options        = undef
           $ppa_package        = 'python-software-properties'
-      } elsif $xfacts['lsbdistcodename'] == 'precise' {
+        }
+        '12.04': {
           $ppa_options        = '-y'
           $ppa_package        = 'python-software-properties'
-      } elsif versioncmp($xfacts['lsbdistrelease'], '14.04') >= 0 {
+        }
+        '14.04', '14.10', '15.04', '15.10', '16.04': {
           $ppa_options        = '-y'
           $ppa_package        = 'software-properties-common'
-      } else {
+        }
+        default: {
           $ppa_options        = '-y'
           $ppa_package        = 'python-software-properties'
+        }
       }
     }
     undef: {
-      fail('Unable to determine lsbdistid, please install lsb-release first')
+      fail('Unable to determine value for fact os["name"]')
     }
     default: {
       $ppa_options = undef
index dff2c297c0c08b3d6f353e69a1d88732dbc904a2..ee32de4694a5a50c7dda1cd48f89c8c1de214da7 100644 (file)
@@ -2,23 +2,20 @@
 # pin a release in apt, useful for unstable repositories
 
 define apt::pin(
-  $ensure          = present,
-  $explanation     = undef,
-  $order           = 50,
-  $packages        = '*',
-  $priority        = 0,
-  $release         = '', # a=
-  $origin          = '',
-  $version         = '',
-  $codename        = '', # n=
-  $release_version = '', # v=
-  $component       = '', # c=
-  $originator      = '', # o=
-  $label           = ''  # l=
+  Optional[Enum['file', 'present', 'absent']] $ensure = present,
+  Optional[String] $explanation                       = undef,
+  Variant[Integer] $order                             = 50,
+  Variant[String, Array] $packages                    = '*',
+  Variant[Numeric, String] $priority                  = 0,
+  Optional[String] $release                           = '', # a=
+  Optional[String] $origin                            = '',
+  Optional[String] $version                           = '',
+  Optional[String] $codename                          = '', # n=
+  Optional[String] $release_version                   = '', # v=
+  Optional[String] $component                         = '', # c=
+  Optional[String] $originator                        = '', # o=
+  Optional[String] $label                             = '',  # l=
 ) {
-  if $order and !is_integer($order) {
-    fail('Only integers are allowed in the apt::pin order param')
-  }
 
   if $explanation {
     $_explanation = $explanation
@@ -36,7 +33,8 @@ define apt::pin(
     $release_version,
     $component,
     $originator,
-    $label]
+    $label,
+  ]
   $pin_release = join($pin_release_array, '')
 
   # Read the manpage 'apt_preferences(5)', especially the chapter
@@ -71,10 +69,28 @@ define apt::pin(
   # be silently ignored.
   $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
 
+  $headertmp = epp('apt/_header.epp')
+
+  $pinpreftmp = epp('apt/pin.pref.epp', {
+      'name'            => $name,
+      'pin_release'     => $pin_release,
+      'release'         => $release,
+      'codename'        => $codename,
+      'release_version' => $release_version,
+      'component'       => $component,
+      'originator'      => $originator,
+      'label'           => $label,
+      'version'         => $version,
+      'origin'          => $origin,
+      'explanation'     => $_explanation,
+      'packages_string' => $packages_string,
+      'priority'        => $priority,
+  })
+
   apt::setting { "pref-${file_name}":
     ensure        => $ensure,
     priority      => $order,
-    content       => template('apt/_header.erb', 'apt/pin.pref.erb'),
+    content       => "${headertmp}${pinpreftmp}",
     notify_update => false,
   }
 }
index 6b025d7a72bea1ff2fb18701cc9d481375bd4560..a67e1a19457e204ce7e5cfb1237115b0081bbc0d 100644 (file)
@@ -1,21 +1,21 @@
 # ppa.pp
 define apt::ppa(
-  $ensure         = 'present',
-  $options        = $::apt::ppa_options,
-  $release        = $::apt::xfacts['lsbdistcodename'],
-  $package_name   = $::apt::ppa_package,
-  $package_manage = false,
+  String $ensure                 = 'present',
+  Optional[String] $options      = $::apt::ppa_options,
+  Optional[String] $release      = $facts['lsbdistcodename'],
+  Optional[String] $package_name = $::apt::ppa_package,
+  Boolean $package_manage        = false,
 ) {
   unless $release {
     fail('lsbdistcodename fact not available: release parameter required')
   }
 
-  if $::apt::xfacts['lsbdistid'] == 'Debian' {
+  if $facts['lsbdistid'] == 'Debian' {
     fail('apt::ppa is not currently supported on Debian.')
   }
 
-  if versioncmp($::apt::xfacts['lsbdistrelease'], '15.10') >= 0 {
-    $distid = downcase($::apt::xfacts['lsbdistid'])
+  if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 {
+    $distid = downcase($facts['lsbdistid'])
     $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2-${release}")
   } else {
     $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2-${release}")
@@ -28,7 +28,6 @@ define apt::ppa(
   if $ensure == 'present' {
     if $package_manage {
       ensure_packages($package_name)
-
       $_require = [File['sources.list.d'], Package[$package_name]]
     } else {
       $_require = File['sources.list.d']
index b0fb62b1debd8fb5d90c1f86cb0f0bdc5e778a7f..507ec9495d66ac2e6d305f71596996d34e7e1973 100644 (file)
@@ -1,12 +1,11 @@
 define apt::setting (
-  $priority      = 50,
-  $ensure        = file,
-  $source        = undef,
-  $content       = undef,
-  $notify_update = true,
+  Variant[String, Integer, Array] $priority           = 50,
+  Optional[Enum['file', 'present', 'absent']] $ensure = file,
+  Optional[String] $source                            = undef,
+  Optional[String] $content                           = undef,
+  Boolean $notify_update                              = true,
 ) {
 
-  include 'apt::params'
   if $content and $source {
     fail('apt::setting cannot have both content and source')
   }
@@ -15,9 +14,6 @@ define apt::setting (
     fail('apt::setting needs either of content or source')
   }
 
-  validate_re($ensure,  ['file', 'present', 'absent'])
-  validate_bool($notify_update)
-
   $title_array = split($title, '-')
   $setting_type = $title_array[0]
   $base_name = join(delete_at($title_array, 0), '-')
@@ -29,22 +25,14 @@ define apt::setting (
     validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer')
   }
 
-  if $source {
-    validate_string($source)
-  }
-
-  if $content {
-    validate_string($content)
-  }
-
   if ($setting_type == 'list') or ($setting_type == 'pref') {
     $_priority = ''
   } else {
     $_priority = $priority
   }
 
-  $_path = $::apt::params::config_files[$setting_type]['path']
-  $_ext  = $::apt::params::config_files[$setting_type]['ext']
+  $_path = $::apt::config_files[$setting_type]['path']
+  $_ext  = $::apt::config_files[$setting_type]['ext']
 
   if $notify_update {
     $_notify = Class['apt::update']
index 5b8e4b18ce36eb2e5ab20a115c83434c9fe17677..be743eb26ca207fc9a3c2b09f82a52caff3ae494 100644 (file)
@@ -1,76 +1,28 @@
 # source.pp
 # add an apt source
 define apt::source(
-  $location          = undef,
-  $comment           = $name,
-  $ensure            = present,
-  $release           = undef,
-  $repos             = 'main',
-  $include           = {},
-  $key               = undef,
-  $pin               = undef,
-  $architecture      = undef,
-  $allow_unsigned    = false,
-  $include_src       = undef,
-  $include_deb       = undef,
-  $required_packages = undef,
-  $key_server        = undef,
-  $key_content       = undef,
-  $key_source        = undef,
-  $trusted_source    = undef,
-  $notify_update     = true,
+  Optional[String] $location           = undef,
+  String $comment                      = $name,
+  String $ensure                       = present,
+  Optional[String] $release            = undef,
+  String $repos                        = 'main',
+  Optional[Variant[Hash]] $include     = {},
+  Optional[Variant[String, Hash]] $key = undef,
+  $pin                                 = undef,
+  Optional[String] $architecture       = undef,
+  Boolean $allow_unsigned              = false,
+  Boolean $notify_update               = true,
 ) {
-  validate_string($architecture, $comment, $location, $repos)
-  validate_bool($allow_unsigned)
-  validate_hash($include)
 
   # This is needed for compat with 1.8.x
   include ::apt
 
   $_before = Apt::Setting["list-${title}"]
 
-  if $include_src != undef {
-    deprecation('apt $include_src', "\$include_src is deprecated and will be removed in the next major release, please use \$include => { 'src' => ${include_src} } instead")
-  }
-
-  if $include_deb != undef {
-    deprecation('apt $include_deb', "\$include_deb is deprecated and will be removed in the next major release, please use \$include => { 'deb' => ${include_deb} } instead")
-  }
-
-  if $required_packages != undef {
-    deprecation('apt $required_packages', '$required_packages is deprecated and will be removed in the next major release, please use package resources instead.')
-    exec { "Required packages: '${required_packages}' for ${name}":
-      command     => "${::apt::params::provider} -y install ${required_packages}",
-      logoutput   => 'on_failure',
-      refreshonly => true,
-      tries       => 3,
-      try_sleep   => 1,
-      before      => $_before,
-    }
-  }
-
-  if $key_server != undef {
-    deprecation('apt $key_server', "\$key_server is deprecated and will be removed in the next major release, please use \$key => { 'server' => ${key_server} } instead.")
-  }
-
-  if $key_content != undef {
-    deprecation('apt $key_content', "\$key_content is deprecated and will be removed in the next major release, please use \$key => { 'content' => ${key_content} } instead.")
-  }
-
-  if $key_source != undef {
-    deprecation('apt $key_source', "\$key_source is deprecated and will be removed in the next major release, please use \$key => { 'source' => ${key_source} } instead.")
-  }
-
-  if $trusted_source != undef {
-    deprecation('apt $trusted_source', '$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.')
-    $_allow_unsigned = $trusted_source
-  } else {
-    $_allow_unsigned = $allow_unsigned
-  }
-
-  if ! $release {
-    $_release = $::apt::params::xfacts['lsbdistcodename']
-    unless $_release {
+  if !$release {
+    if $facts['lsbdistcodename'] {
+      $_release = $facts['lsbdistcodename']
+    } else {
       fail('lsbdistcodename fact not available: release parameter required')
     }
   } else {
@@ -81,42 +33,35 @@ define apt::source(
     fail('cannot create a source entry without specifying a location')
   }
 
-  if $include_src != undef and $include_deb != undef {
-    $_deprecated_include = {
-      'src' => $include_src,
-      'deb' => $include_deb,
-    }
-  } elsif $include_src != undef {
-    $_deprecated_include = { 'src' => $include_src }
-  } elsif $include_deb != undef {
-    $_deprecated_include = { 'deb' => $include_deb }
-  } else {
-    $_deprecated_include = {}
-  }
-
-  $_include = merge($::apt::params::include_defaults, $_deprecated_include, $include)
-
-  $_deprecated_key = {
-    'key_server'  => $key_server,
-    'key_content' => $key_content,
-    'key_source'  => $key_source,
-  }
+  $includes = merge($::apt::include_defaults, $include)
 
   if $key {
     if is_hash($key) {
       unless $key['id'] {
         fail('key hash must contain at least an id entry')
       }
-      $_key = merge($::apt::params::source_key_defaults, $_deprecated_key, $key)
+      $_key = merge($::apt::source_key_defaults, $key)
     } else {
-      validate_string($key)
-      $_key = merge( { 'id' => $key }, $_deprecated_key)
+      validate_legacy(String, 'validate_string', $key)
+      $_key = { 'id' => $key }
     }
   }
 
+  $header = epp('apt/_header.epp')
+
+  $sourcelist = epp('apt/source.list.epp', {
+    'comment'          => $comment,
+    'includes'         => $includes,
+    'opt_architecture' => $architecture,
+    'allow_unsigned'   => $allow_unsigned,
+    'location'         => $location,
+    'release'          => $_release,
+    'repos'            => $repos,
+  })
+
   apt::setting { "list-${name}":
     ensure        => $ensure,
-    content       => template('apt/_header.erb', 'apt/source.list.erb'),
+    content       => "${header}${sourcelist}",
     notify_update => $notify_update,
   }
 
@@ -142,16 +87,13 @@ define apt::source(
   if $key and ($ensure == 'present') {
     if is_hash($_key) {
       apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
-        ensure      => present,
-        id          => $_key['id'],
-        server      => $_key['server'],
-        content     => $_key['content'],
-        source      => $_key['source'],
-        options     => $_key['options'],
-        key_server  => $_key['key_server'],
-        key_content => $_key['key_content'],
-        key_source  => $_key['key_source'],
-        before      => $_before,
+        ensure  => present,
+        id      => $_key['id'],
+        server  => $_key['server'],
+        content => $_key['content'],
+        source  => $_key['source'],
+        options => $_key['options'],
+        before  => $_before,
       }
     }
   }
index 44f6c6e301ca37f4d48ca4357a2301928db5cc79..4cc6ec523f578c47ea3f3c61e3bacf2f2029395c 100644 (file)
@@ -54,6 +54,7 @@ class apt::update {
   }
   exec { 'apt_update':
     command     => "${::apt::provider} update",
+    loglevel    => $::apt::_update['loglevel'],
     logoutput   => 'on_failure',
     refreshonly => $_refresh,
     timeout     => $::apt::_update['timeout'],
index 1b21a5c193f04f7c33ed38ce39c991bc82b7fb92..4e65705322cf6e65663e3224b75eecbc388f1052 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-apt",
-  "version": "2.3.0",
+  "version": "4.1.0",
   "author": "Puppet Labs",
   "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet",
   "license": "Apache-2.0",
@@ -8,22 +8,21 @@
   "project_page": "https://github.com/puppetlabs/puppetlabs-apt",
   "issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
   "dependencies": [
-    {"name":"puppetlabs/stdlib","version_requirement":">= 4.13.0 < 5.0.0"}
+    {"name":"puppetlabs/stdlib","version_requirement":">= 4.16.0 < 5.0.0"}
   ],
+  "data_provider": null,
   "operatingsystem_support": [
     {
       "operatingsystem": "Debian",
       "operatingsystemrelease": [
-        "6",
         "7",
-        "8"
+        "8",
+        "9"
       ]
     },
     {
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
-        "10.04",
-        "12.04",
         "14.04",
         "16.04"
       ]
@@ -32,7 +31,7 @@
   "requirements": [
     {
       "name": "puppet",
-      "version_requirement": ">= 3.0.0 < 5.0.0"
+      "version_requirement": ">= 4.7.0 < 6.0.0"
     }
   ]
 }
index 52415f5afaecb4e0cfe28fbe2af689c3ffad3f77..df312a756041025184ffd2c8d21f5f0de5b7d601 100644 (file)
@@ -33,8 +33,8 @@ describe 'apt class' do
       class { 'apt':
         update => {
           'frequency' => 'always',
-          'timeout'   => '400',
-          'tries'     => '3',
+          'timeout'   => 400,
+          'tries'     => 3,
         },
         purge => {
           'sources.list'   => true,
index 5762025eaff44ad5002bc3d58e7ad983f4589084..f2172d92a99396031c349062a70725e4eed2cbea 100644 (file)
@@ -7,6 +7,7 @@ describe 'apt::backports', :type => :class do
     context 'defaults on deb' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'wheezy',
@@ -14,7 +15,7 @@ describe 'apt::backports', :type => :class do
         }
       end
       it { is_expected.to contain_apt__source('backports').with({
-        :location => 'http://httpredir.debian.org/debian',
+        :location => 'http://deb.debian.org/debian',
         :key      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
         :repos    => 'main contrib non-free',
         :release  => 'wheezy-backports',
@@ -22,27 +23,10 @@ describe 'apt::backports', :type => :class do
       })
       }
     end
-    context 'defaults on squeeze' do
-      let(:facts) do
-        {
-          :lsbdistid       => 'Debian',
-          :osfamily        => 'Debian',
-          :lsbdistcodename => 'squeeze',
-          :puppetversion   => Puppet.version,
-        }
-      end
-      it { is_expected.to contain_apt__source('backports').with({
-        :location => 'http://httpredir.debian.org/debian-backports',
-        :key      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-        :repos    => 'main contrib non-free',
-        :release  => 'squeeze-backports',
-        :pin      => { 'priority' => 200, 'release' => 'squeeze-backports' },
-      })
-      }
-    end
     context 'defaults on ubuntu' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
@@ -62,6 +46,7 @@ describe 'apt::backports', :type => :class do
     context 'set everything' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
@@ -90,6 +75,7 @@ describe 'apt::backports', :type => :class do
     context 'set things with hashes' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
@@ -117,6 +103,7 @@ describe 'apt::backports', :type => :class do
   describe 'mint tests' do
     let(:facts) do
       {
+        :os => { :family => 'Debian', :name => 'Linuxmint', :release => { :major => '17', :full => '17' }},
         :lsbdistid       => 'linuxmint',
         :osfamily        => 'Debian',
         :lsbdistcodename => 'qiana',
@@ -201,6 +188,7 @@ describe 'apt::backports', :type => :class do
   describe 'validation' do
     let(:facts) do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistid       => 'Ubuntu',
         :osfamily        => 'Debian',
         :lsbdistcodename => 'trusty',
@@ -217,7 +205,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /is not a string/)
+        }.to raise_error(Puppet::Error, /expects a/)
       end
     end
     context 'invalid release' do
@@ -229,7 +217,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /is not a string/)
+        }.to raise_error(Puppet::Error, /expects a/)
       end
     end
     context 'invalid repos' do
@@ -241,7 +229,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /is not a string/)
+        }.to raise_error(Puppet::Error, /expects a/)
       end
     end
     context 'invalid key' do
@@ -253,7 +241,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /is not a string/)
+        }.to raise_error(Puppet::Error, /expects a/)
       end
     end
     context 'invalid pin' do
@@ -265,7 +253,7 @@ describe 'apt::backports', :type => :class do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/)
+        }.to raise_error(Puppet::Error, /expects a/)
       end
     end
   end
index 53ef7bea49a1805ced7de19670db36464dd499b9..cd3a6ec7b47f4253418e531179c9804ad5fb5394 100644 (file)
@@ -1,7 +1,14 @@
 require 'spec_helper'
 describe 'apt' do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version} }
-
+  let(:facts) do
+  {
+    :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+    :lsbdistid       => 'Debian',
+    :osfamily        => 'Debian',
+    :lsbdistcodename => 'wheezy',
+    :puppetversion   => Puppet.version,
+  }
+  end
   context 'defaults' do
     it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({
       :ensure  => 'file',
@@ -137,9 +144,11 @@ describe 'apt' do
 
   context 'with sources defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      { :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
-        :lsbdistid       => 'Debian',
+        :lsbdistid       => 'Ubuntu',
+        :lsbdistrelease  => '12.04',
         :puppetversion   => Puppet.version,
       }
     end
@@ -179,7 +188,9 @@ describe 'apt' do
 
   context 'with confs defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
         :lsbdistid       => 'Debian',
         :puppetversion   => Puppet.version,
@@ -205,7 +216,9 @@ describe 'apt' do
 
   context 'with keys defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
         :lsbdistid       => 'Debian',
         :puppetversion   => Puppet.version,
@@ -231,7 +244,9 @@ describe 'apt' do
 
   context 'with ppas defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
         :lsbdistid       => 'ubuntu',
         :lsbdistrelease  => '12.04',
@@ -249,7 +264,9 @@ describe 'apt' do
 
   context 'with settings defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
         :lsbdistid       => 'Debian',
         :puppetversion   => Puppet.version,
@@ -266,7 +283,9 @@ describe 'apt' do
 
   context 'with pins defined on valid osfamily' do
     let :facts do
-      { :osfamily        => 'Debian',
+      {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }},
+        :osfamily        => 'Debian',
         :lsbdistcodename => 'precise',
         :lsbdistid       => 'Debian',
         :puppetversion   => Puppet.version,
@@ -317,17 +336,5 @@ describe 'apt' do
         }.to raise_error(Puppet::Error)
       end
     end
-
-    context 'with unsupported osfamily' do
-      let :facts do
-        { :osfamily => 'Darwin', :puppetversion   => Puppet.version,}
-      end
-
-      it do
-        expect {
-          subject.call
-        }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
-      end
-    end
   end
 end
index d031104ddd2f3ce81c924f6a160543f13e8e9e29..bc199f8575222459322abea4e23f3696f5503505 100644 (file)
@@ -3,10 +3,23 @@ require 'spec_helper'
 
 describe 'apt::update', :type => :class do
   context "and apt::update['frequency']='always'" do
-    { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+    {
+      'a recent run'                                 => Time.now.to_i,
+      'we are due for a run'                         => 1406660561,
+      'the update-success-stamp file does not exist' => -1,
+    }.each_pair do |desc, factval|
       context "and $::apt_update_last_success indicates #{desc}" do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
-        let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" }
+        let(:facts) { {
+          :os                      => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+          :lsbdistid               => 'Debian',
+          :osfamily                => 'Debian',
+          :apt_update_last_success => factval,
+          :lsbdistcodename         => 'wheezy',
+          :puppetversion           => Puppet.version,
+        } }
+        let (:pre_condition) {
+          "class{'::apt': update => {'frequency' => 'always' },}"
+        }
         it 'should trigger an apt-get update run' do
           #set the apt_update exec's refreshonly attribute to false
           is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
@@ -14,7 +27,13 @@ describe 'apt::update', :type => :class do
       end
     end
     context 'when $::apt_update_last_success is nil' do
-      let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+      let(:facts) { {
+        :os              => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+        :lsbdistid       => 'Debian',
+        :osfamily        => 'Debian',
+        :lsbdistcodename => 'wheezy',
+        :puppetversion   => Puppet.version,
+      } }
       let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
       it 'should trigger an apt-get update run' do
         #set the apt_update exec\'s refreshonly attribute to false
@@ -23,9 +42,20 @@ describe 'apt::update', :type => :class do
     end
   end
   context "and apt::update['frequency']='reluctantly'" do
-    {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+    {
+      'a recent run'                                 => Time.now.to_i,
+      'we are due for a run'                         => 1406660561,
+      'the update-success-stamp file does not exist' => -1,
+    }.each_pair do |desc, factval|
       context "and $::apt_update_last_success indicates #{desc}" do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version,} }
+        let(:facts) { {
+          :os                      => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+          :lsbdistid               => 'Debian',
+          :osfamily                => 'Debian',
+          :apt_update_last_success => factval,
+          :lsbdistcodename         => 'wheezy',
+          :puppetversion           => Puppet.version,
+        } }
         let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
         it 'should not trigger an apt-get update run' do
           #don't change the apt_update exec's refreshonly attribute. (it should be true)
@@ -34,7 +64,13 @@ describe 'apt::update', :type => :class do
       end
     end
     context 'when $::apt_update_last_success is nil' do
-      let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+      let(:facts) { {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+        :lsbdistid       => 'Debian',
+        :osfamily        => 'Debian',
+        :lsbdistcodename => 'wheezy',
+        :puppetversion   => Puppet.version,
+      } }
       let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
       it 'should not trigger an apt-get update run' do
         #don't change the apt_update exec's refreshonly attribute. (it should be true)
@@ -46,7 +82,14 @@ describe 'apt::update', :type => :class do
     context "and apt::update['frequency'] has the value of #{update_frequency}" do
       { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
         context "and $::apt_update_last_success indicates #{desc}" do
-          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+          let(:facts) { {
+            :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+            :lsbdistid               => 'Debian',
+            :osfamily                => 'Debian',
+            :apt_update_last_success => factval,
+            :lsbdistcodename         => 'wheezy',
+            :puppetversion           => Puppet.version,
+          } }
           let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
           it 'should trigger an apt-get update run' do
             #set the apt_update exec\'s refreshonly attribute to false
@@ -55,7 +98,14 @@ describe 'apt::update', :type => :class do
         end
       end
       context 'when the $::apt_update_last_success fact has a recent value' do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion   => Puppet.version, } }
+        let(:facts) { {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+          :lsbdistid               => 'Debian',
+          :osfamily                => 'Debian',
+          :lsbdistcodename         => 'wheezy',
+          :apt_update_last_success => Time.now.to_i,
+          :puppetversion           => Puppet.version,
+        } }
         let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
         it 'should not trigger an apt-get update run' do
           #don't change the apt_update exec\'s refreshonly attribute. (it should be true)
@@ -63,7 +113,14 @@ describe 'apt::update', :type => :class do
         end
       end
       context 'when $::apt_update_last_success is nil' do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion   => Puppet.version, } }
+        let(:facts) { {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+          :lsbdistid               => 'Debian',
+          :osfamily                => 'Debian',
+          :lsbdistcodename         => 'wheezy',
+          :apt_update_last_success => nil,
+          :puppetversion           => Puppet.version,
+        } }
         let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
         it 'should trigger an apt-get update run' do
           #set the apt_update exec\'s refreshonly attribute to false
diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb
deleted file mode 100644 (file)
index 3161cf0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper'
-describe 'apt::params', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
-
-  # There are 4 resources in this class currently
-  # there should not be any more resources because it is a params class
-  # The resources are class[apt::params], class[main], class[settings], stage[main]
-  it "Should not contain any resources" do
-    expect(subject.call.resources.size).to eq(4)
-  end
-
-  describe "With lsb-release not installed" do
-    let(:facts) { { :osfamily => 'Debian', :puppetversion => Puppet.version, } }
-    let (:title) { 'my_package' }
-
-    it do
-      expect {
-        subject.call
-      }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, please install lsb-release first/)
-    end
-  end
-end
index c74bf1aca340265897e3c1d8fcfcb24850cde4a3..16507c2f6fd9adc360d4e25b551a48ab86fd5253 100644 (file)
@@ -3,7 +3,13 @@ describe 'apt::conf', :type => :define do
   let :pre_condition do
     'class { "apt": }'
   end
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+  let(:facts) { {
+    :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+    :lsbdistid       => 'Debian',
+    :osfamily        => 'Debian',
+    :lsbdistcodename => 'wheezy',
+    :puppetversion   => Puppet.version,
+  } }
   let :title do
     'norecommends'
   end
index eaf53fca45e495ccf0c52e44fae974ed3e6c3c97..dab9d16586ff342cbfba2a43ac4d302b7b8e1330 100644 (file)
@@ -2,8 +2,9 @@ require 'spec_helper'
 
 describe 'apt::key', :type => :define do
   let(:facts) { {
-    :lsbdistid => 'Debian',
-    :osfamily => 'Debian',
+    :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+    :lsbdistid     => 'Debian',
+    :osfamily      => 'Debian',
     :puppetversion => Puppet.version,
   } }
   GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
@@ -25,7 +26,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       }
       it 'contains the apt_key present anchor' do
@@ -39,7 +39,7 @@ describe 'apt::key', :type => :define do
       end
 
       let :params do {
-        :key => GPG_KEY_ID,
+        :id => GPG_KEY_ID,
       } end
 
       it 'contains the apt_key' do
@@ -49,7 +49,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       end
       it 'contains the apt_key present anchor' do
@@ -69,7 +68,6 @@ describe 'apt::key', :type => :define do
           :source            => nil,
           :server            => 'keyserver.ubuntu.com',
           :content           => nil,
-          :keyserver_options => nil,
         })
       end
       it 'contains the apt_key absent anchor' do
@@ -79,10 +77,10 @@ describe 'apt::key', :type => :define do
 
     describe 'set a bunch of things!' do
       let :params do {
-        :key_content => 'GPG key content',
-        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-        :key_server => 'pgp.mit.edu',
-        :key_options => 'debug',
+        :content => 'GPG key content',
+        :source => 'http://apt.puppetlabs.com/pubkey.gpg',
+        :server => 'pgp.mit.edu',
+        :options => 'debug',
       } end
 
       it 'contains the apt_key' do
@@ -91,7 +89,7 @@ describe 'apt::key', :type => :define do
           :ensure  => 'present',
           :source  => 'http://apt.puppetlabs.com/pubkey.gpg',
           :server  => 'pgp.mit.edu',
-          :content => params[:key_content],
+          :content => params[:content],
           :options => 'debug',
         })
       end
@@ -102,7 +100,7 @@ describe 'apt::key', :type => :define do
 
     context "domain with dash" do
       let(:params) do{
-        :key_server => 'p-gp.m-it.edu',
+        :server => 'p-gp.m-it.edu',
       } end
       it 'contains the apt_key' do
         is_expected.to contain_apt_key(title).with({
@@ -115,7 +113,7 @@ describe 'apt::key', :type => :define do
     context "url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu',
+          :server => 'hkp://pgp.mit.edu',
         }
       end
       it 'contains the apt_key' do
@@ -128,7 +126,7 @@ describe 'apt::key', :type => :define do
     context "url with port number" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:80',
+          :server => 'hkp://pgp.mit.edu:80',
         }
       end
       it 'contains the apt_key' do
@@ -143,7 +141,7 @@ describe 'apt::key', :type => :define do
   describe 'validation' do
     context "domain begin with dash" do
       let(:params) do{
-        :key_server => '-pgp.mit.edu',
+        :server => '-pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -152,7 +150,7 @@ describe 'apt::key', :type => :define do
 
     context "domain begin with dot" do
       let(:params) do{
-        :key_server => '.pgp.mit.edu',
+        :server => '.pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -161,7 +159,7 @@ describe 'apt::key', :type => :define do
 
     context "domain end with dot" do
       let(:params) do{
-        :key_server => "pgp.mit.edu.",
+        :server => "pgp.mit.edu.",
       } end
       it 'fails' do
         expect { subject.call } .to raise_error(/does not match/)
@@ -170,7 +168,7 @@ describe 'apt::key', :type => :define do
     context "exceed character url" do
       let :params do
         {
-          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+          :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
         }
       end
       it 'fails' do
@@ -180,7 +178,7 @@ describe 'apt::key', :type => :define do
     context "incorrect port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:8008080'
+          :server => 'hkp://pgp.mit.edu:8008080'
         }
       end
       it 'fails' do
@@ -190,7 +188,7 @@ describe 'apt::key', :type => :define do
     context "incorrect protocol for  url" do
       let :params do
         {
-          :key_server => 'abc://pgp.mit.edu:80'
+          :server => 'abc://pgp.mit.edu:80'
         }
       end
       it 'fails' do
@@ -200,7 +198,7 @@ describe 'apt::key', :type => :define do
     context "missing port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:'
+          :server => 'hkp://pgp.mit.edu:'
         }
       end
       it 'fails' do
@@ -210,7 +208,7 @@ describe 'apt::key', :type => :define do
     context "url ending with a dot" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu.'
+          :server => 'hkp://pgp.mit.edu.'
         }
       end
       it 'fails' do
@@ -219,7 +217,7 @@ describe 'apt::key', :type => :define do
     end
     context "url begin with a dash" do
       let(:params) do{
-        :key_server => "hkp://-pgp.mit.edu",
+        :server => "hkp://-pgp.mit.edu",
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -236,7 +234,7 @@ describe 'apt::key', :type => :define do
 
     context 'invalid source' do
       let :params do {
-        :key_source => 'afp://puppetlabs.com/key.gpg',
+        :source => 'afp://puppetlabs.com/key.gpg',
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -245,16 +243,16 @@ describe 'apt::key', :type => :define do
 
     context 'invalid content' do
       let :params do {
-        :key_content => [],
+        :content => [],
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/expects a/)
       end
     end
 
     context 'invalid server' do
       let :params do {
-        :key_server => 'two bottles of rum',
+        :server => 'two bottles of rum',
       } end
       it 'fails' do
         expect { subject.call }.to raise_error(/does not match/)
@@ -263,10 +261,10 @@ describe 'apt::key', :type => :define do
 
     context 'invalid keyserver_options' do
       let :params do {
-        :key_options => {},
+        :options => {},
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/expects a/)
       end
     end
 
@@ -277,19 +275,19 @@ describe 'apt::key', :type => :define do
         }
       end
       it 'fails' do
-        expect { subject.call }.to raise_error(/does not match/)
+        expect { subject.call }.to raise_error(/Enum\['absent', 'present'\]/)
       end
     end
 
     describe 'duplication' do
       context 'two apt::key resources for same key, different titles' do
         let :pre_condition do
-          "#{super()}\napt::key { 'duplicate': key => '#{title}', }"
+          "#{super()}\napt::key { 'duplicate': id => '#{title}', }"
         end
 
         it 'contains the duplicate apt::key resource' do
           is_expected.to contain_apt__key('duplicate').with({
-            :key    => title,
+            :id    => title,
             :ensure => 'present',
           })
         end
@@ -319,7 +317,7 @@ describe 'apt::key', :type => :define do
 
       context 'two apt::key resources, different ensure' do
         let :pre_condition do
-          "#{super()}\napt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+          "#{super()}\napt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
           expect { subject.call }.to raise_error(/already ensured as absent/)
index 1ebcfc7af0c655b2637e84f449b86190c062a39e..334924d2b7ce1fdcbf468dc2d1d30f18ae386881 100644 (file)
@@ -5,7 +5,13 @@ describe 'apt::key' do
     'class { "apt": }'
   end
 
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+  let(:facts) { {
+    :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+    :lsbdistid       => 'Debian',
+    :osfamily        => 'Debian',
+    :lsbdistcodename => 'wheezy',
+    :puppetversion   => Puppet.version,
+  } }
 
   GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
 
@@ -245,7 +251,7 @@ describe 'apt::key' do
         :content => [],
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/expects a/)
       end
     end
 
@@ -263,7 +269,7 @@ describe 'apt::key' do
         :options => {},
       } end
       it 'fails' do
-        expect { subject.call }.to raise_error(/is not a string/)
+        expect { subject.call }.to raise_error(/expects a/)
       end
     end
 
@@ -275,7 +281,7 @@ describe 'apt::key' do
           }
           end
         it 'fails' do
-          expect { subject.call }.to raise_error(/does not match/)
+          expect { subject.call }.to raise_error(/for Enum\['absent', 'present'\], got/)
         end
       end
     end
index 9fb28c66523ec3816c24d3b7de57b5115a4b9c49..50890fcf6b8be39d4fa8991dbe8285be2e2bd561 100644 (file)
@@ -3,23 +3,27 @@ describe 'apt::pin', :type => :define do
   let :pre_condition do
     'class { "apt": }'
   end
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+  let(:facts) { {
+    :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+    :lsbdistid       => 'Debian',
+    :osfamily        => 'Debian',
+    :lsbdistcodename => 'wheezy',
+    :puppetversion   => Puppet.version,
+  } }
   let(:title) { 'my_pin' }
 
   context 'defaults' do
     it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_apt__setting("pref-my_pin") }
   end
 
   context 'set version' do
     let :params do
       {
         'packages' => 'vim',
-        'version'  => '1',
+        'version'  => "1",
       }
     end
     it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_apt__setting("pref-my_pin") }
   end
 
   context 'set origin' do
@@ -30,7 +34,6 @@ describe 'apt::pin', :type => :define do
       }
     end
     it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_apt__setting("pref-my_pin") }
   end
 
   context 'not defaults' do
@@ -81,7 +84,7 @@ describe 'apt::pin', :type => :define do
       it do
         expect {
           subject.call
-        }.to raise_error(Puppet::Error, /Only integers are allowed/)
+        }.to raise_error(Puppet::Error, /expects an Integer value, got String/)
       end
     end
 
index a4c30142e872b7edf17fe507933a9235967d5025..f95776f6ee83dfa386d4c5f379a3fea59e550814 100644 (file)
@@ -7,6 +7,7 @@ describe 'apt::ppa' do
   describe 'defaults' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '11', :full => '11.04' }},
         :lsbdistrelease  => '11.04',
         :lsbdistcodename => 'natty',
         :operatingsystem => 'Ubuntu',
@@ -31,6 +32,7 @@ describe 'apt::ppa' do
   describe 'Ubuntu 15.10 sources.list filename' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '15', :full => '15.10' }},
         :lsbdistrelease  => '15.10',
         :lsbdistcodename => 'wily',
         :operatingsystem => 'Ubuntu',
@@ -69,6 +71,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '11', :full => '11.04' }},
         :lsbdistrelease  => '11.04',
         :lsbdistcodename => 'natty',
         :operatingsystem => 'Ubuntu',
@@ -104,6 +107,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '11', :full => '11.04' }},
         :lsbdistrelease  => '11.04',
         :lsbdistcodename => 'natty',
         :operatingsystem => 'Ubuntu',
@@ -141,6 +145,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '11', :full => '11.04' }},
         :lsbdistrelease  => '11.04',
         :lsbdistcodename => 'natty',
         :operatingsystem => 'Ubuntu',
@@ -180,6 +185,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistrelease  => '14.04',
         :lsbdistcodename => 'trusty',
         :operatingsystem => 'Ubuntu',
@@ -216,6 +222,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistrelease  => '14.04',
         :lsbdistcodename => 'trusty',
         :operatingsystem => 'Ubuntu',
@@ -250,6 +257,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistrelease  => '14.04',
         :lsbdistcodename => 'trusty',
         :operatingsystem => 'Ubuntu',
@@ -284,6 +292,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistrelease  => '14.04',
         :lsbdistcodename => 'trusty',
         :operatingsystem => 'Ubuntu',
@@ -316,6 +325,7 @@ describe 'apt::ppa' do
     end
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistrelease  => '14.04',
         :lsbdistcodename => 'trusty',
         :operatingsystem => 'Ubuntu',
@@ -340,6 +350,7 @@ describe 'apt::ppa' do
     describe 'no release' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistrelease  => '14.04',
           :operatingsystem => 'Ubuntu',
           :lsbdistid       => 'Ubuntu',
@@ -359,6 +370,7 @@ describe 'apt::ppa' do
     describe 'not ubuntu' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '6', :full => '6.0.7' }},
           :lsbdistrelease  => '6.0.7',
           :lsbdistcodename => 'wheezy',
           :operatingsystem => 'Debian',
index e1163a0df894f6c3ce5709888e960ae62ae6d8ac..cdba3124e75e787899155efdf4efdce7b910ce47 100644 (file)
@@ -2,7 +2,17 @@ require 'spec_helper'
 
 describe 'apt::setting' do
   let(:pre_condition) { 'class { "apt": }' }
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+  let :facts do
+    {
+      :os => { :distro => { :codename => 'wheezy' }, :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+      :lsbdistrelease  => '7.0',
+      :lsbdistcodename => 'wheezy',
+      :operatingsystem => 'Debian',
+      :osfamily        => 'Debian',
+      :lsbdistid       => 'Debian',
+      :puppetversion   => Puppet.version,
+    }
+  end
   let(:title) { 'conf-teddybear' }
 
   let(:default_params) { { :content => 'di' } }
@@ -61,7 +71,13 @@ describe 'apt::setting' do
       apt::setting { "list-teddybear": content => "foo" }
       '
     end
-    let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion   => Puppet.version, } }
+    let(:facts) { {
+      :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+      :lsbdistid       => 'Debian',
+      :osfamily        => 'Debian',
+      :lsbdistcodename => 'wheezy',
+      :puppetversion   => Puppet.version,
+    } }
     let(:title) { 'conf-teddybear' }
     let(:default_params) { { :content => 'di' } }
 
@@ -82,21 +98,21 @@ describe 'apt::setting' do
       let(:title) { 'ext-teddybear' }
       let(:params) { default_params }
       it do
-        expect { subject.call }.to raise_error(Puppet::Error, /must start with /)
+        expect { subject.call }.to raise_error(Puppet::Error, /must start with either/)
       end
     end
 
     context 'with ensure=banana' do
       let(:params) { default_params.merge({ :ensure => 'banana' }) }
       it do
-        expect { subject.call }.to raise_error(Puppet::Error, /"banana" does not /)
+        expect { subject.call }.to raise_error(Puppet::Error, /Enum\['absent', 'file', 'present'\]/)
       end
     end
 
     context 'with priority=1.2' do
       let(:params) { default_params.merge({ :priority => 1.2 }) }
-      if Puppet.version.to_f >= 4.0 || ENV["FUTURE_PARSER"] == 'yes'
-        it { is_expected.to compile.and_raise_error(/input needs to be a String/) }
+      if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') >= 0 || ENV["FUTURE_PARSER"] == 'yes'
+        it { is_expected.to compile.and_raise_error(/expects a value of type/) }
       else
         it { is_expected.to compile.and_raise_error(/priority must be an integer or a zero-padded integer/) }
       end
index 5da846f7149702eef1d6c1fcc50e324ddaaa4da9..88cd625e1a5bcad94b9d5ce9c21517130698b044 100644 (file)
@@ -10,6 +10,7 @@ describe 'apt::source', :type => :define do
   context 'mostly defaults' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -19,8 +20,7 @@ describe 'apt::source', :type => :define do
 
     let :params do
       {
-        'include_deb' => false,
-        'include_src' => true,
+        'include' => { 'deb' => false, 'src' => true },
         'location'    => 'http://debian.mirror.iweb.ca/debian/',
       }
     end
@@ -32,6 +32,7 @@ describe 'apt::source', :type => :define do
   context 'no defaults' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -40,19 +41,15 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'comment'           => 'foo',
-        'location'          => 'http://debian.mirror.iweb.ca/debian/',
-        'release'           => 'sid',
-        'repos'             => 'testing',
-        'include_src'       => false,
-        'required_packages' => 'vim',
-        'key'               => GPG_KEY_ID,
-        'key_server'        => 'pgp.mit.edu',
-        'key_content'       => 'GPG key content',
-        'key_source'        => 'http://apt.puppetlabs.com/pubkey.gpg',
-        'pin'               => '10',
-        'architecture'      => 'x86_64',
-        'trusted_source'    => true,
+        'comment'        => 'foo',
+        'location'       => 'http://debian.mirror.iweb.ca/debian/',
+        'release'        => 'sid',
+        'repos'          => 'testing',
+        'include'        => { 'src' => false },
+        'key'            => GPG_KEY_ID,
+        'pin'            => '10',
+        'architecture'   => 'x86_64',
+        'allow_unsigned' => true,
       }
     end
 
@@ -66,28 +63,17 @@ describe 'apt::source', :type => :define do
     })
     }
 
-    it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
-      'command'     => '/usr/bin/apt-get -y install vim',
-      'logoutput'   => 'on_failure',
-      'refreshonly' => true,
-      'tries'       => '3',
-      'try_sleep'   => '1',
-    })
-    }
-
     it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
       'ensure' => 'present',
       'id'  => GPG_KEY_ID,
-      'key_server' => 'pgp.mit.edu',
-      'key_content' => 'GPG key content',
-      'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
     })
     }
   end
 
-  context 'trusted_source true' do
+  context 'allow_unsigned true' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -96,9 +82,9 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'include_src'    => false,
+        'include'        => {'src' => false},
         'location'       => 'http://debian.mirror.iweb.ca/debian/',
-        'trusted_source' => true,
+        'allow_unsigned' => true,
       }
     end
 
@@ -108,6 +94,7 @@ describe 'apt::source', :type => :define do
   context 'architecture equals x86_64' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -128,6 +115,7 @@ describe 'apt::source', :type => :define do
   context 'ensure => absent' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -150,6 +138,7 @@ describe 'apt::source', :type => :define do
     context 'no release' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :puppetversion   => Puppet.version,
index bf6977a39dd0e0f4cf456bf890615f1010391bc2..79cc11b990d782ec58ef7f9e84a4c352a3ce0e3d 100644 (file)
@@ -15,9 +15,9 @@ describe 'apt::source' do
     context 'without location' do
       let :facts do
         {
-          :lsbdistid       => 'Debian',
-          :lsbdistcodename => 'wheezy',
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :osfamily        => 'Debian',
+          :lsbdistcodename => 'wheezy',
           :puppetversion   => Puppet.version,
         }
       end
@@ -30,6 +30,7 @@ describe 'apt::source' do
     context 'with location' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :lsbdistcodename => 'wheezy',
           :osfamily        => 'Debian',
@@ -48,9 +49,12 @@ describe 'apt::source' do
   describe 'no defaults' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
+        :operatingsystem => 'Debian',
+        :lsbdistrelease  => '7.0',
         :puppetversion   => Puppet.version,
       }
     end
@@ -189,6 +193,7 @@ describe 'apt::source' do
   context 'allow_unsigned true' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -211,6 +216,7 @@ describe 'apt::source' do
   context 'architecture equals x86_64' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -220,7 +226,7 @@ describe 'apt::source' do
     let :params do
       {
         :location     => 'hello.there',
-        :include      => {'deb' => false, 'src' => true,},
+        :include      => {'deb' => false, 'src' => true},
         :architecture => 'x86_64',
       }
     end
@@ -231,9 +237,11 @@ describe 'apt::source' do
     }
   end
 
-  context 'include_src => true' do
+  context 'with architecture fact and unset architecture parameter' do
     let :facts do
       {
+        :architecture    => 'amd64',
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -242,43 +250,44 @@ describe 'apt::source' do
     end
     let :params do
       {
-        :location    => 'hello.there',
-        :include_src => true,
+        :location => 'hello.there',
+        :include  => {'deb' => false, 'src' => true,},
       }
     end
 
     it { is_expected.to contain_apt__setting('list-my_source').with({
       :ensure => 'present',
-    }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
+    }).with_content(/# my_source\ndeb-src hello.there wheezy main\n/)
     }
   end
 
-  context 'include_deb => false' do
+  context 'include_src => true' do
     let :facts do
       {
-        :lsbdistid       => 'debian',
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+        :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
-        :osfamily        => 'debian',
+        :osfamily        => 'Debian',
         :puppetversion   => Puppet.version,
       }
     end
     let :params do
       {
         :location    => 'hello.there',
-        :include_deb => false,
+        :include     => {'src' => true},
       }
     end
 
     it { is_expected.to contain_apt__setting('list-my_source').with({
       :ensure => 'present',
-    }).without_content(/deb-src hello.there wheezy main\n/)
+    }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
     }
-    it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
   end
 
-  context 'include_src => true and include_deb => false' do
+  context 'include deb => false' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'debian',
@@ -287,22 +296,22 @@ describe 'apt::source' do
     end
     let :params do
       {
+        :include => { 'deb' => false },
         :location    => 'hello.there',
-        :include_deb => false,
-        :include_src => true,
       }
     end
 
     it { is_expected.to contain_apt__setting('list-my_source').with({
       :ensure => 'present',
-    }).with_content(/deb-src hello.there wheezy main\n/)
+    }).without_content(/deb-src hello.there wheezy main\n/)
     }
     it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
   end
 
-  context 'include precedence' do
+  context 'include src => true and include deb => false' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'debian',
@@ -311,10 +320,8 @@ describe 'apt::source' do
     end
     let :params do
       {
+        :include => { 'deb' => false, 'src' => true },
         :location    => 'hello.there',
-        :include_deb => true,
-        :include_src => false,
-        :include     => { 'deb' => false, 'src' => true },
       }
     end
 
@@ -328,6 +335,7 @@ describe 'apt::source' do
   context 'ensure => absent' do
     let :facts do
       {
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
@@ -350,6 +358,7 @@ describe 'apt::source' do
     context 'no release' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :puppetversion   => Puppet.version,
@@ -364,9 +373,24 @@ describe 'apt::source' do
       end
     end
 
+    context 'release is empty string' do
+      let :facts do
+        {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+          :lsbdistid       => 'Debian',
+          :osfamily        => 'Debian',
+          :puppetversion   => Puppet.version,
+        }
+      end
+      let(:params) { { :location => 'hello.there', :release => '' } }
+
+      it { is_expected.to contain_apt__setting('list-my_source').with_content(/hello\.there  main/) }
+    end
+
     context 'invalid pin' do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :lsbdistcodename => 'wheezy',
           :osfamily        => 'Debian',
@@ -390,6 +414,7 @@ describe 'apt::source' do
     context "with notify_update = undef (default)" do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :lsbdistcodename => 'wheezy',
           :osfamily        => 'Debian',
@@ -407,6 +432,7 @@ describe 'apt::source' do
     context "with notify_update = true" do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :lsbdistcodename => 'wheezy',
           :osfamily        => 'Debian',
@@ -425,6 +451,7 @@ describe 'apt::source' do
     context "with notify_update = false" do
       let :facts do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :lsbdistcodename => 'wheezy',
           :osfamily        => 'Debian',
index bcd6bb55477eb3a75daf5d4fa0a49bb19187deb2..d030e0f536145fa199b012deb2d77428eb560860 100644 (file)
@@ -26,7 +26,7 @@ describe 'apt_has_updates fact' do
       File.stubs(:executable?) # Stub all other calls
       Facter::Util::Resolution.stubs(:exec) # Catch all other calls
       File.expects(:executable?).with('/usr/bin/apt-get').returns true
-      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+
+      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns ""+
         "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+
diff --git a/spec/unit/facter/apt_package_security_updates_spec.rb b/spec/unit/facter/apt_package_security_updates_spec.rb
new file mode 100644 (file)
index 0000000..868375e
--- /dev/null
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'apt_package_security_updates fact' do
+  subject { Facter.fact(:apt_package_security_updates).value }
+  after(:each) { Facter.clear }
+
+  describe 'when apt has no updates' do
+    before { 
+      Facter.fact(:apt_has_updates).stubs(:value).returns false
+    }
+    it { is_expected.to be nil }
+  end
+
+  describe 'when apt has updates' do
+    before { 
+      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+      File.stubs(:executable?) # Stub all other calls
+      Facter::Util::Resolution.stubs(:exec) # Catch all other calls
+      File.expects(:executable?).with('/usr/bin/apt-get').returns true
+      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns ""+
+        "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
+        "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
+        "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+
+        "Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"
+    }
+    it {
+      if Facter.version < '2.0.0'
+        is_expected.to eq('tzdata')
+      else
+        is_expected.to eq(['tzdata'])
+      end
+    }
+  end
+end
index d7587ca99632312cfa4760e26f8e4ee213057809..49ceceeb93bd477e83584cbcc8f71002956cdadf 100644 (file)
@@ -17,7 +17,7 @@ describe 'apt_package_updates fact' do
       File.stubs(:executable?) # Stub all other calls
       Facter::Util::Resolution.stubs(:exec) # Catch all other calls
       File.expects(:executable?).with('/usr/bin/apt-get').returns true
-      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+
+      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns ""+
         "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+
index 174b60d6b6497cf87e1379740c05be32cd2d41cd..f0dcab2cde3e178d4efc048d7877ce17a243f4bd 100644 (file)
@@ -17,7 +17,7 @@ describe 'apt_security_updates fact' do
       File.stubs(:executable?) # Stub all other calls
       Facter::Util::Resolution.stubs(:exec) # Catch all other calls
       File.expects(:executable?).with('/usr/bin/apt-get').returns true
-      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+
+      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns ""+
         "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+
index cb32a5ef02cf25d686c797375185ba80a9599530..ada6aa58947aaf8c2ec4a324071a68dbf346da80 100644 (file)
@@ -2,25 +2,22 @@ require 'spec_helper'
 
 describe 'apt_update_last_success fact' do
   subject { Facter.fact(:apt_update_last_success).value }
+  before(:each) { Facter.clear }
   after(:each) { Facter.clear }
 
   describe 'on Debian based distro which has not yet created the update-success-stamp file' do
-    before {
-      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
-      File.stubs(:exists?).returns false
-    }
     it 'should have a value of -1' do
+      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+      File.expects(:exists?).with('/var/lib/apt/periodic/update-success-stamp').returns false
       is_expected.to eq(-1)
     end
   end
 
   describe 'on Debian based distro which has created the update-success-stamp' do
-    before {
+    it 'should have the value of the mtime of the file' do
       Facter.fact(:osfamily).stubs(:value).returns 'Debian'
       File.stubs(:exists?).returns true
       File.stubs(:mtime).returns 1407660561
-    }
-    it 'should have the value of the mtime of the file' do
       is_expected.to eq(1407660561)
     end
   end
index 8c726fc343539f101daab2cc64fe80f3588a9b61..d2c2bf24bdd5860c07292934c7fe7081a8f2ae14 100644 (file)
@@ -17,7 +17,7 @@ describe 'apt_updates fact' do
       File.stubs(:executable?) # Stub all other calls
       Facter::Util::Resolution.stubs(:exec) # Catch all other calls
       File.expects(:executable?).with('/usr/bin/apt-get').returns true
-      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s upgrade 2>&1').returns ""+
+      Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns ""+
         "Inst tzdata [2015f-0+deb8u1] (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Conf tzdata (2015g-0+deb8u1 Debian:stable-updates [all])\n"+
         "Inst unhide.rb [13-1.1] (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"+
similarity index 100%
rename from templates/_header.erb
rename to templates/_header.epp
diff --git a/templates/conf.erb b/templates/conf.erb
deleted file mode 100644 (file)
index a35d1d4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= @content -%>
diff --git a/templates/pin.pref.epp b/templates/pin.pref.epp
new file mode 100644 (file)
index 0000000..7991332
--- /dev/null
@@ -0,0 +1,26 @@
+<%- | $name, $pin_release, $release, $codename, $release_version, $component, $originator, $label, $version, $origin, $explanation, $packages_string, $priority | -%>
+<%-
+$pin =
+if $pin_release.length > 0 {
+  $options = [
+    if $release         { "a=${release}" },
+    if $codename        { "n=${codename}" },
+    if $release_version { "v=${release_version}"},
+    if $component       { "c=${component}" },
+    if $originator      { "o=${originator}" },
+    if $label           { "l=${label}" },
+    ].filter |$x| { $x != undef }
+   "release ${options.join(', ')}" }
+
+elsif $version and "${version}".length > 0 {
+   "version ${version}" }
+elsif $origin and $origin.length > 0 {
+   "origin ${origin}" }
+else {
+  "release a=${name}" #Default value
+}
+-%>
+Explanation: <%= $explanation %>
+Package: <%= $packages_string %>
+Pin: <%= $pin %>
+Pin-Priority: <%= $priority %>
diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb
deleted file mode 100644 (file)
index 76936d7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<%-
-@pin = "release a=#{@name}" # default value
-if @pin_release.length > 0
-  options = []
-  options.push("a=#{@release}") if @release.length > 0
-  options.push("n=#{@codename}") if @codename.length > 0
-  options.push("v=#{@release_version}") if @release_version.length > 0
-  options.push("c=#{@component}") if @component.length > 0
-  options.push("o=#{@originator}") if @originator.length > 0
-  options.push("l=#{@label}") if @label.length > 0
-  @pin = "release #{options.join(', ')}"
-elsif @version.length > 0
-  @pin = "version #{@version}"
-elsif @origin.length > 0
-  @pin = "origin #{@origin}"
-end
--%>
-Explanation: <%= @_explanation %>
-Package: <%= @packages_string %>
-Pin: <%= @pin %>
-Pin-Priority: <%= @priority %>
diff --git a/templates/proxy.epp b/templates/proxy.epp
new file mode 100644 (file)
index 0000000..0cbccb8
--- /dev/null
@@ -0,0 +1,5 @@
+<%- | Hash $proxies | -%>
+Acquire::http::proxy "http://<%= $proxies['host'] %>:<%= $proxies['port'] %>/";
+<%- if $proxies['https'] { %>
+Acquire::https::proxy "https://<%= $proxies['host'] %>:<%= $proxies['port'] %>/";
+<%- } -%>
diff --git a/templates/proxy.erb b/templates/proxy.erb
deleted file mode 100644 (file)
index 670e3a7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Acquire::http::proxy "http://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/";
-<%- if @_proxy['https'] %>
-Acquire::https::proxy "https://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/";
-<%- end -%>
diff --git a/templates/source.list.epp b/templates/source.list.epp
new file mode 100644 (file)
index 0000000..4b29726
--- /dev/null
@@ -0,0 +1,10 @@
+<%- | String $comment, Hash $includes, $opt_architecture, Boolean $allow_unsigned, $location, $release, String $repos | -%>
+# <%= $comment %>
+<%- if $includes['deb'] { -%>
+deb <%- if ($opt_architecture or $allow_unsigned) {-%>
+ [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
+<%- } -%>
+<%- if $includes['src'] { -%>
+deb-src <%- if $opt_architecture or $allow_unsigned { -%>
+ [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
+<%- } -%>
diff --git a/templates/source.list.erb b/templates/source.list.erb
deleted file mode 100644 (file)
index 84cd2cf..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# <%= @comment %>
-<%- if @_include['deb'] then -%>
-deb <%- if @architecture or @_allow_unsigned -%>
-[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %>
-<%- end -%>
-<%- if @_include['src'] then -%>
-deb-src <%- if @architecture or @_allow_unsigned -%>
-[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %>
-<%- end -%>