]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #640 from ocadotechnology/dpkg_admin_lock
authorTP Honey <tphoney@users.noreply.github.com>
Tue, 11 Jul 2017 10:19:15 +0000 (11:19 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2017 10:19:15 +0000 (11:19 +0100)
(MODULES-4118) Set dpkg option NoLocking in apt_updates fact

52 files changed:
.fixtures.yml
.gitattributes
.gitignore
.project
.sync.yml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile
MAINTAINERS.md [new file with mode: 0644]
NOTICE
README.md
Rakefile
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
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/spec.opts [deleted file]
spec/spec_helper.rb
spec/spec_helper_acceptance.rb
spec/unit/facter/apt_update_last_success_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 578437cb9f0074e35ffb8b504f5f6c600d8c4b23..0c221f0da7306aa9c8f020cfcd70fc146e5f175f 100644 (file)
@@ -2,6 +2,5 @@ fixtures:
   repositories:
     "stdlib":
       "repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
-      "ref": "4.5.0"
   symlinks:
     "apt": "#{source_dir}"
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 0cd25de9afb0e3ed0bdc5f3b72d6d4e2362c2d33..f6e8b46c29ee7fb0d148126fec3ff54c4192f676 100644 (file)
@@ -1,12 +1,24 @@
 #This file is generated by ModuleSync, do not edit.
 pkg/
 Gemfile.lock
+Gemfile.local
 vendor/
 spec/fixtures/manifests/
 spec/fixtures/modules/
+log/
+junit/
 .vagrant/
 .bundle/
 coverage/
 log/
 .idea/
+.metadata
 *.iml
+.*.sw[op]
+.yardoc
+.yardwarns
+.DS_Store
+tmp/
+vendor/
+doc/
+
index 6523c6dafadca0f6e24c1d29d1364dbb00735d53..102070e0aa386b7a3e8c9391716191107c32fb76 100644 (file)
--- a/.project
+++ b/.project
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>apt</name>
+       <name>puppetlabs-apt</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
-                       <name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
+                       <name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
@@ -17,7 +17,7 @@
                </buildCommand>
        </buildSpec>
        <natures>
-               <nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
+               <nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature>
                <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
        </natures>
 </projectDescription>
index bf2a8818d404a26265f23d40f7260e3096ed34f1..dd596277d31bc7a8364c03475e78bb6d52347b20 100644 (file)
--- a/.sync.yml
+++ b/.sync.yml
@@ -1,6 +1,14 @@
 ---
+appveyor.yml:
+  delete: true
 # override default cells to replace centos-7 with debian-8
 .travis.yml:
   docker_sets:
   - set: docker/ubuntu-14.04
   - set: docker/debian-8
+
+NOTICE:
+  unmanaged: true
+
+spec/spec_helper.rb:
+  allow_deprecations: true
index 00e21af1cf15fc7c86816303fdd864870a9c89a5..9af2623346e9f99b2ec1de6c65724024f09610fc 100644 (file)
@@ -3,7 +3,7 @@
 sudo: false
 language: ruby
 cache: bundler
-script: "bundle exec rake validate lint spec"
+script: "bundle exec rake release_checks"
 #Inserting below due to the following issue: https://github.com/travis-ci/travis-ci/issues/3531#issuecomment-88311203
 before_install:
   - gem update bundler
@@ -22,20 +22,11 @@ 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"
+    env: PUPPET_GEM_VERSION="~> 5.0"
   - rvm: 2.1.9
     bundler_args: --without system_tests
     env: PUPPET_GEM_VERSION="~> 4.0"
-  - rvm: 2.1.5
-    bundler_args: --without system_tests
-    env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
-  - rvm: 2.1.5
-    bundler_args: --without system_tests
-    env: PUPPET_GEM_VERSION="~> 3.0"
-  - rvm: 1.9.3
-    bundler_args: --without system_tests
-    env: PUPPET_GEM_VERSION="~> 3.0"
 notifications:
   email: false
index 44cc4f8f71120c82cdead8602875a38ff2e765f7..c6765a4acb4128376e1fe5d662869f21ec444868 100644 (file)
@@ -1,3 +1,52 @@
+## 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.
+
+## 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 +70,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 +89,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 +187,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 +207,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 +249,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 +259,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 +277,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 +331,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 +341,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 +379,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 +403,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 +429,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 +470,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 +485,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 +499,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 +514,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 3c3f1e79997c90de7e3b08202667ef8c72c65bac..990edba7e70c856cb84c64affdafa9b4f98aa110 100644 (file)
@@ -43,7 +43,7 @@ Checklist (and a short version for the impatient)
 
       - Make sure you have a [GitHub account](https://github.com/join)
 
-      - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for.
+      - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
 
     * Preferred method:
 
@@ -215,4 +215,3 @@ Additional Resources
 * [General GitHub documentation](http://help.github.com/)
 
 * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
-
diff --git a/Gemfile b/Gemfile
index 8871c66381bdb95d7f16f41271354d09db712f7a..46cb2eacec6c449052b3e1f7aad6aa8e1bbd5956 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -29,36 +29,27 @@ 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
-  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
-  gem 'mocha', '< 1.2.0',                   :require => false
-  gem 'simplecov',                          :require => false
-  gem 'parallel_tests', '< 2.10.0',         :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
-  gem 'parallel_tests',                     :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0')
-  gem 'rubocop', '0.41.2',                  :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
-  gem 'rubocop',                            :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0')
-  gem 'rubocop-rspec', '~> 1.6',            :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
-  gem 'pry',                                :require => false
-  gem 'json_pure', '<= 2.0.1',              :require => false if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
+  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}",       :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'] || '~> 2.20')                if supports_windows
-  gem 'beaker', *location_for(ENV['BEAKER_VERSION'])                             if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0') and ! supports_windows
-  gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '< 3')                    if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') and ! supports_windows
-  gem 'beaker-pe',                                                               :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
-  gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4')     if ! supports_windows
-  gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '~> 5.1')     if supports_windows
-  gem 'beaker-puppet_install_helper',                                            :require => false
-  gem 'master_manipulator',                                                      :require => false
-  gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
+  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')        
 end
 
 gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644 (file)
index 0000000..0b11ea2
--- /dev/null
@@ -0,0 +1,6 @@
+## Maintenance
+
+Maintainers:
+  - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com`
+
+Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `apt`.
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..ac945b40933428c3aaeb32a8021fd92664d48563 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':
@@ -150,7 +150,7 @@ apt::source { 'puppetlabs':
     'id'     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
     'server' => 'pgp.mit.edu',
   },
-},
+}
 ```
 
 ### Configure Apt from Hiera
@@ -160,7 +160,7 @@ include the `apt` class, which will pick up the values automatically from
 hiera.
 
 ```yaml
-apt::sources:
+apt::source:
   'debian_unstable':
     comment: 'This is the iWeb Debian unstable mirror'
     location: 'http://debian.mirror.iweb.ca/debian/'
@@ -192,21 +192,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',
index 3e8d4cb9526d1ac226aa591ea64ac558f905e50a..d12d85495d735b72ada9cb125a3b9ce13db13561 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,9 @@
-require 'puppet_blacksmith/rake_tasks'
-require 'puppet-lint/tasks/puppet-lint'
 require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
 
+PuppetLint.configuration.fail_on_warnings = true
 PuppetLint.configuration.send('relative')
-PuppetLint.configuration.send('disable_documentation')
-PuppetLint.configuration.send('disable_single_quote_string_with_variables')
 
 desc 'Generate pooler nodesets'
 task :gen_nodeset do
index d7e85dafaf5a1e6ab762153f137394a49cc52d47..668fd0f18d2ee35c0addb98e1bd365956d7f2a11 100644 (file)
@@ -127,9 +127,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..07c0b9b
--- /dev/null
@@ -0,0 +1,25 @@
+---
+# 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:
+  
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..c89c2230cfd684c108acb924ca74868f345e8222 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':
index 914ec88ca4e92f1861899a76c33cd7938b6e76de..dfa1daf2b61935886b79cf22b5876511807397c4 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 {
-    warning('$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 {
-    warning('$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 {
-    warning('$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 {
-    warning('$key_server is deprecated and will be removed in the next major release. Please use $server instead.')
-    $_server = $key_server
-  } else {
-    $_server = $server
-  }
-
-  if $key_options != undef {
-    warning('$key_options is deprecated and will be removed in the next major release. Please use $options instead.')
-    $_options = $key_options
-  } else {
-    $_options = $options
-  }
-
-  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+'])
-  }
+  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 $_server {
-    validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
+  if $source {
+    validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
   }
 
-  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": }
       }
     }
 
     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..bcff6bd40d293cde5ed273e6d55495b2a252075a 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'   => {
@@ -86,10 +69,10 @@ class apt::params {
     'src' => false,
   }
 
-  case $xfacts['lsbdistid'] {
-    'debian': {
-      case $xfacts['lsbdistcodename'] {
-        'squeeze': {
+  case $facts['os']['name']{
+    'Debian': {
+      case $facts['os']['release']['full'] {
+        '6.0': {
           $backports = {
             'location' => 'http://httpredir.debian.org/debian-backports',
             'key'      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
@@ -109,29 +92,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': {
           $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 9adf6a2336ee764db234216e1cf0b20b413ef48a..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 {
-    warning("\$include_src is deprecated and will be removed in the next major release, please use \$include => { 'src' => ${include_src} } instead")
-  }
-
-  if $include_deb != undef {
-    warning("\$include_deb is deprecated and will be removed in the next major release, please use \$include => { 'deb' => ${include_deb} } instead")
-  }
-
-  if $required_packages != undef {
-    warning('$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 {
-    warning("\$key_server is deprecated and will be removed in the next major release, please use \$key => { 'server' => ${key_server} } instead.")
-  }
-
-  if $key_content != undef {
-    warning("\$key_content is deprecated and will be removed in the next major release, please use \$key => { 'content' => ${key_content} } instead.")
-  }
-
-  if $key_source != undef {
-    warning("\$key_source is deprecated and will be removed in the next major release, please use \$key => { 'source' => ${key_source} } instead.")
-  }
-
-  if $trusted_source != undef {
-    warning('$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,
   }
 
@@ -124,8 +69,8 @@ define apt::source(
     if is_hash($pin) {
       $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before })
     } elsif (is_numeric($pin) or is_string($pin)) {
-      $url_split = split($location, '/')
-      $host      = $url_split[2]
+      $url_split = split($location, '[:\/]+')
+      $host      = $url_split[1]
       $_pin = {
         'ensure'   => $ensure,
         'priority' => $pin,
@@ -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 d34221c752bedbd55829b1e0a5071381f3a038b9..ac0ff6c9defa649a00ede899db6f1c78e9ea73ab 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,8 +8,9 @@
   "project_page": "https://github.com/puppetlabs/puppetlabs-apt",
   "issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
   "dependencies": [
-    {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0 < 5.0.0"}
+    {"name":"puppetlabs/stdlib","version_requirement":">= 4.16.0 < 5.0.0"}
   ],
+  "data_provider": null,
   "operatingsystem_support": [
     {
       "operatingsystem": "Debian",
@@ -32,7 +33,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..1dfbf3759d61868aa53c75e10f24950b9d6d63d6 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',
@@ -25,6 +26,7 @@ describe 'apt::backports', :type => :class do
     context 'defaults on squeeze' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '6', :full => '6.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'squeeze',
@@ -43,6 +45,7 @@ describe 'apt::backports', :type => :class do
     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 +65,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 +94,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 +122,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 +207,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 +224,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 +236,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 +248,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 +260,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 +272,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 a326bdbdd3239c400319eb199b127ef88f5fe6a7..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,23 @@ 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 }) }
-      it do
-        expect { subject.call }.to raise_error(Puppet::Error, /be an integer /)
+      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
     end
   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',
diff --git a/spec/spec.opts b/spec/spec.opts
deleted file mode 100644 (file)
index 91cd642..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
---format
-s
---colour
---loadby
-mtime
---backtrace
index 9ae37b172941cfc5d206f6168c4dbab7748f48d7..22d5d689f4616681ae30d187d834009cebf008e3 100644 (file)
@@ -1,14 +1,6 @@
 #This file is generated by ModuleSync, do not edit.
 require 'puppetlabs_spec_helper/module_spec_helper'
 
-if Puppet.version.to_f >= 4.5
-  RSpec.configure do |c|
-    c.before :each do
-      Puppet.settings[:strict] = :error
-    end
-  end
-end
-
 # put local configuration and setup into spec_helper_local
 begin
   require 'spec_helper_local'
index a5ce06fc45815156e2d32c61377f97d04de21701..30eccbf625d362e901791f3bbdb16478f99032f1 100644 (file)
@@ -1,7 +1,10 @@
 require 'beaker-rspec'
 require 'beaker/puppet_install_helper'
+require 'beaker/module_install_helper'
 
 run_puppet_install_helper
+install_module_on(hosts)
+install_module_dependencies_on(hosts)
 
 UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris']
 
@@ -37,14 +40,4 @@ RSpec.configure do |c|
 
   # Readable test descriptions
   c.formatter = :documentation
-
-  # Configure all nodes in nodeset
-  c.before :suite do
-    # Install module and dependencies
-    hosts.each do |host|
-      copy_module_to(host, :source => proj_root, :module_name => 'apt')
-      shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
-      on host, puppet('module install puppetlabs-stdlib --version 4.5.0'), { :acceptable_exit_codes => [0,1] }
-    end
-  end
 end
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
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 -%>