puppetlabs-apt-2.2.0/000755 000766 000024 00000000000 12602537570 014722 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/CHANGELOG.md000644 000766 000024 00000044716 12602537177 016552 0ustar00bmjenstaff000000 000000 ##2015-09-29 - Supported Release 2.2.0 ###Summary This release includes a few bugfixes. ####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 - 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 This release includes a few 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 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 - Add API compatibility to `apt::key` and `apt::source` - Added `apt_reboot_required` fact ####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 This bug fixes a few compatibility issues that came up with the 2.0.0 release, and includes test and documentation updates. ####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 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 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` - `keyserver_options` parameter renamed to `options` #####`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` - 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` - This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_testing.pp) #####`apt::debian::unstable` - This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_unstable.pp) #####`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` - This define was removed. Simply use an `apt::pin` with `priority => 1001` for the same functionality. #####`apt` - `always_apt_update` - This parameter was removed. Use `update => { 'frequency' => 'always' }` instead. - `apt_update_frequency` - This parameter was removed. Use `update => { 'frequency' => }` instead. - `disable_keys` - This parameter was removed. See this [example](examples/disable_keys.pp) if you need this functionality. - `proxy_host` - This parameter was removed. Use `proxy => { 'host' => }` instead. - `proxy_port` - This parameter was removed. Use `proxy => { 'port' => }` instead. - `purge_sources_list` - This parameter was removed. Use `purge => { 'sources.list' => }` instead. - `purge_sources_list_d` - This parameter was removed. Use `purge => { 'sources.list.d' => }` instead. - `purge_preferences` - This parameter was removed. Use `purge => { 'preferences' => }` instead. - `purge_preferences_d` - This parameter was removed. Use `purge => { 'preferences.d' => }` instead. - `update_timeout` - This parameter was removed. Use `update => { 'timeout' => }` instead. - `update_tries` - This parameter was removed. Use `update => { 'tries' => }` instead. #####`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` - This class was removed. See this [example](examples/release.pp) for how to achieve this functionality. #####`apt::source` - `include_src` - This parameter was removed. Use `include => { 'src' => }` instead. ***NOTE*** This now defaults to false. - `include_deb` - This parameter was removed. Use `include => { 'deb' => }` instead. - `required_packages` - This parameter was removed. Use package resources for these packages if needed. - `key` - This can either be a key id or a hash including key options. If using a hash, `key => { 'id' => }` must be specified. - `key_server` - This parameter was removed. Use `key => { 'server' => }` instead. - `key_content` - This parameter was removed. Use `key => { 'content' => }` instead. - `key_source` - This parameter was removed. Use `key => { 'source' => }` instead. - `trusted_source` - This parameter was renamed to `allow_unsigned`. #####`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 - 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 - 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 - Fixes for strict variables. ##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 - The apt module will now throw warnings if you don't use full fingerprints for `apt_key`s ####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 - Add support for full fingerprints - New parameter for `apt::source` - `trusted_source` - New parameters for `apt::ppa` - `package_name` - `package_manage` - New parameter for `apt::unattended_upgrades` - `legacy_origin` - Separate `apt::pin` from `apt::backports` to allow pin by release instead of origin ####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) - Allow 5 digit ports in `apt_key` - Fix for `ensure => absent` in `apt_key` (MODULES-1661) - Fix `apt_has_updates` not parsing `apt-check` output correctly - Fix inconsistent headers across files (MODULES-1200) - Clean up formatting for 50unattended-upgrades.erb ##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 - Updated unit and acceptance tests - Update module to work with Linux Mint - Documentation updates - Future parser / strict variables support - Improved support for long GPG keys - New parameters! - Added `apt_update_frequency` to apt - Added `cfg_files` and `cfg_missing` parameters to apt::force - Added `randomsleep` to apt::unattended_upgrades - Added `apt_update_last_success` fact - Refactored facts for performance improvements ####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 ####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 - Allow dashes in URL or domain for key_server parameter ##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 - Synced files from Modulesync ####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 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 This release has added tests to ensure graceful failure on OSX. ##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 apt_key, which allows you to use puppet resource apt_key to inventory keys on your system. Special thanks to daenney, our intrepid unofficial apt maintainer! ####Features - Add support for Ubuntu Trusty! - Add apt::hold define - Generate valid *.pref files in apt::pin - Made pin_priority configurable for apt::backports - Add apt_key type and provider - Rename "${apt_conf_d}/proxy" to "${apt_conf_d}/01proxy" - apt::key rewritten to use apt_key type - Add support for update_tries to apt::update ####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 This is a supported release. This release tidies up 1.4.1 and re-enables support for Ubuntu 10.04 ####Features ####Bugfixes - Fix apt:ppa to include the -y Ubuntu 10.04 requires. - Documentation changes. - Test fixups. ####Known Bugs * No known issues. ##2014-02-13 1.4.1 ###Summary This is a bugfix release. ####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 - Correct apt::source template when architecture is provided - Retry package installs if apt is locked - Use root to exec in apt::ppa - Updated tests and converted acceptance tests to beaker ##2013-10-08 - Release 1.4.0 ###Summary Minor bugfix and allow the timeout to be adjusted. ####Features - Add an `updates_timeout` to apt::params ####Bugfixes - Ensure apt::ppa can read a ppa removed by hand. ##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 specific packages to automatically upgrade without any further user involvement. In addition we extend our Wheezy support, add proxy support to apt:ppa and do various cleanups and tweaks. ####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 - Fix regsubst() calls to quote single letters (for future parser). - Fix lint warnings and other misc cleanup. ##2013-07-03 - Release 1.2.0 ####Features - Add geppetto `.project` natures - Add GH auto-release - Add `apt::key::key_options` parameter - Add complex pin support using distribution properties for `apt::pin` via new properties: - `apt::pin::codename` - `apt::pin::release_version` - `apt::pin::component` - `apt::pin::originator` - `apt::pin::label` - Add source architecture support to `apt::source::architecture` ####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 This is a bug fix release that resolves a number of issues: * By changing template variable usage, we remove the deprecation warnings for Puppet 3.2.x * Fixed proxy file removal, when proxy absent Some documentation, style and whitespaces changes were also merged. This release also introduced proper rspec-puppet unit testing on Travis-CI to help reduce regression. Thanks to all the community contributors below that made this patch possible. #### Detail Changes * fix minor comment type (Chris Rutter) * whitespace fixes (Michael Moll) * Update travis config file (William Van Hevelingen) * Build all branches on travis (William Van Hevelingen) * Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) * Updated content to conform to README best practices template (Lauren Rother) * Fix apt::release example in readme (Brian Galey) * add @ to variables in template (Peter Hoeg) * Remove deprecation warnings for pin.pref.erb as well (Ken Barber) * Update travis.yml to latest versions of puppet (Ken Barber) * Fix proxy file removal (Scott Barber) * Add spec test for removing proxy configuration (Dean Reilly) * Fix apt::key listing longer than 8 chars (Benjamin Knofe) ## Release 1.1.0 ###Summary This release includes Ubuntu 12.10 (Quantal) support for PPAs. --- ##2012-05-25 - Puppet Labs - 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 * Allow preferences to be purged * Extend pin support ##2012-05-04 - Puppet Labs - Release 0.0.3 ###Summary * only invoke apt-get update once * only install python-software-properties if a ppa is added * support 'ensure => absent' for all defined types * add apt::conf * add apt::backports * fixed Modulefile for module tool dependency resolution * configure proxy before doing apt-get update * use apt-get update instead of aptitude for apt::ppa * add support to pin release ##2012-03-26 - Puppet Labs - Release 0.0.2 ###Summary * 41cedbb (#13261) Add real examples to smoke tests. * d159a78 (#13261) Add key.pp smoke test * 7116c7a (#13261) Replace foo source with puppetlabs source * 1ead0bf Ignore pkg directory. * 9c13872 (#13289) Fix some more style violations * 0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path * a758247 (#13289) Clean up style violations and fix corresponding tests * 99c3fd3 (#13289) Add puppet lint tests to Rakefile * 5148cbf (#13125) Apt keys should be case insensitive * b9607a4 Convert apt::key to use anchors ##2012-03-07 - Puppet Labs - Release 0.0.1 ###Summary * d4fec56 Modify apt::source release parameter test * 1132a07 (#12917) Add contributors to README * 8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it * 7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input * be2cc3e (#12522) Adjust spec test for splitting purge * 7dc60ae (#12522) Split purge option to spare sources.list * 9059c4e Fix source specs to test all key permutations * 8acb202 Add test for python-software-properties package * a4af11f Check if python-software-properties is defined before attempting to define it. * 1dcbf3d Add tests for required_packages change * f3735d2 Allow duplicate $required_packages * 74c8371 (#12430) Add tests for changes to apt module * 97ebb2d Test two sources with the same key * 1160bcd (#12526) Add ability to reverse apt { disable_keys => true } * 2842d73 Add Modulefile to puppet-apt * c657742 Allow the use of the same key in multiple sources * 8c27963 (#12522) Adding purge option to apt class * 997c9fd (#12529) Add unit test for apt proxy settings * 50f3cca (#12529) Add parameter to support setting a proxy for apt * d522877 (#12094) Replace chained .with_* with a hash * 8cf1bd0 (#12094) Remove deprecated spec.opts file * 2d688f4 (#12094) Add rspec-puppet tests for apt * 0fb5f78 (#12094) Replace name with path in file resources * f759bc0 (#11953) Apt::force passes $version to aptitude * f71db53 (#11413) Add spec test for apt::force to verify changes to unless * 2f5d317 (#11413) Update dpkg query used by apt::force * cf6caa1 (#10451) Add test coverage to apt::ppa * 0dd697d include_src parameter in example; Whitespace cleanup * b662eb8 fix typos in "repositories" * 1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added * 864302a Set the pin priority before adding the source (Fix #10449) * 1de4e0a Refactored as per mlitteken * 1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! * 52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep * 5c05fa0 added builddep command. * a11af50 added the ability to specify the content of a key * c42db0f Fixes ppa test. * 77d2b0d reformatted whitespace to match recommended style of 2 space indentation. * 27ebdfc ignore swap files. * 377d58a added smoke tests for module. * 18f614b reformatted apt::ppa according to recommended style. * d8a1e4e Created a params class to hold global data. * 636ae85 Added two params for apt class * 148fc73 Update LICENSE. * ed2d19e Support ability to add more than one PPA * 420d537 Add call to apt-update after add-apt-repository in apt::ppa * 945be77 Add package definition for python-software-properties * 71fc425 Abs paths for all commands * 9d51cd1 Adding LICENSE * 71796e3 Heading fix in README * 87777d8 Typo in README * f848bac First commit puppetlabs-apt-2.2.0/checksums.json000644 000766 000024 00000012370 12602537570 017605 0ustar00bmjenstaff000000 000000 { "CHANGELOG.md": "e49926ff292a2b21a249ae4e323c6921", "CONTRIBUTING.md": "e2b8e8e433fc76b3798b7fe435f49375", "Gemfile": "bf3e2f7d33eb4497453331532e85a998", "LICENSE": "c236a08bf88c5c8e480957038c869ed1", "README.md": "034d49337ad0c9981a4785c3e81b07e7", "Rakefile": "d953eb985f82600dc3b9ac6e1f2cfe64", "examples/backports.pp": "17882e4b05751cd28069dcc72705e470", "examples/builddep.pp": "eddb8b7d7c0ef7383d85a74c1cd0de3f", "examples/debian_testing.pp": "2e50a41180e2afeac2de15ade05ddaa1", "examples/debian_unstable.pp": "82890803cc4423443db8f40353e16262", "examples/disable_keys.pp": "3d4e7ac49946d961ff51a719ee713293", "examples/fancy_progress.pp": "9a55d4ea52be4ebd670befff7ca3b87f", "examples/force.pp": "f71857eba704a0eb3d8d6b146e80da6d", "examples/hold.pp": "5e58e0a30d6407a05691d96c7647ae14", "examples/key.pp": "d1d63e76f1ca8a004dbeac9261c9045a", "examples/pin.pp": "4b4c3612d75a19dba8eb7227070fa4ab", "examples/ppa.pp": "b902cce8159128b5e8b21bed540743ff", "examples/release.pp": "2bc960babf8c4dd24b7ffa4220a601f8", "examples/source.pp": "2f402ae0218fdf070d5388a66e85f82f", "examples/unattended_upgrades.pp": "e7a797388ef03077f110f4f268f5ecd1", "lib/facter/apt_reboot_required.rb": "7c3fc46f254fc4b4579d011578caaadb", "lib/facter/apt_update_last_success.rb": "2926ff059cd2f63a2a7824ba898837f9", "lib/facter/apt_updates.rb": "6c2f2204761b2d8842e0db6235d900cb", "lib/puppet/provider/apt_key/apt_key.rb": "16e6e4562fdbc80cd0d0c6bd25baceac", "lib/puppet/type/apt_key.rb": "b167dc62db19a482a5b46abf3095904b", "lib/puppet_x/apt_key/patch_openuri.rb": "951bad007a3b5db035be069c1d1c9c09", "manifests/backports.pp": "7d4a6e58ae3dc364e6279358e4f4b957", "manifests/conf.pp": "403cee9be6284d6f47759482759f4b6d", "manifests/init.pp": "3640560b938701bbc0c4ed8c93c5a64a", "manifests/key.pp": "ad58e1224124b5b4a2617123d74eed00", "manifests/params.pp": "a46ba0421ec6c2f3ef181588ed7b9e04", "manifests/pin.pp": "5abe01b9106f1f3c00f02e3ad81eec75", "manifests/ppa.pp": "61d72727867547b9e4b5b3986795249c", "manifests/setting.pp": "cde5492c31b2b94c49bf67c7c96a6058", "manifests/source.pp": "c1be91ad56665839711ada25c6f10850", "manifests/update.pp": "93f132802d6280debfc46b35c656486f", "metadata.json": "250a966dfdbde70657a318a693ac967b", "spec/acceptance/apt_key_provider_spec.rb": "1e19756f710dbc8799b630721197786e", "spec/acceptance/apt_spec.rb": "0bd13c6cb16e56d049ad0a5770f9c1f3", "spec/acceptance/class_spec.rb": "7fa3ee3cade5e27891fe01aa8af8941d", "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151", "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b", "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af", "spec/acceptance/nodesets/debian-70rc1-x64.yml": "715f798e696d3582c66d13f0e8e5f009", "spec/acceptance/nodesets/debian-73-x64.yml": "b44b7146a828c37482c06879862fb5d9", "spec/acceptance/nodesets/default.yml": "e27bb4d7526ad3c7a1c4aeb87decec15", "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297", "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269", "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0", "spec/classes/apt_backports_spec.rb": "20492356c4ebddcfe8739b8f4a0beac6", "spec/classes/apt_spec.rb": "2e13445aff673ff8139e8f0955bd7b19", "spec/classes/apt_update_spec.rb": "e1bae3848f53c709a14c1e6def93865e", "spec/classes/params_spec.rb": "87ac980e35fbc87e4d5a61809b99c1d8", "spec/defines/conf_spec.rb": "4c07a034a6e55098962535d5dca611b0", "spec/defines/key_compat_spec.rb": "3676c87d803d19d92f35ba74bad1db7c", "spec/defines/key_spec.rb": "a69d96e761e40767ee3526503b9ce63c", "spec/defines/pin_spec.rb": "5a3866f7a49f88e6e14e3335872e387b", "spec/defines/ppa_spec.rb": "bb791a23d6a0af69b2a74f48434c6984", "spec/defines/setting_spec.rb": "740578ed09763c7573c0bfafab6c94a1", "spec/defines/source_compat_spec.rb": "c9f46b9aee9a07685984af805b04c057", "spec/defines/source_spec.rb": "4ee084eb7c6531bb419d00f2a8361571", "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", "spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc", "spec/spec_helper_acceptance.rb": "2d4884491c0eed85a780cbe694074945", "spec/unit/facter/apt_has_updates_spec.rb": "fdc0d48ed55ebc72ae16c3f09cf82d2c", "spec/unit/facter/apt_package_updates_spec.rb": "9102ea3ea94a286f5accd2fb2f040725", "spec/unit/facter/apt_reboot_required_spec.rb": "9d58cb2aeaed624f7c4ca118ec1b6410", "spec/unit/facter/apt_security_updates_spec.rb": "41c9c1d84a0feaa3938f6f3d8def9772", "spec/unit/facter/apt_update_last_success_spec.rb": "cbc907ca27e6f9bb803fa9654c4a1836", "spec/unit/facter/apt_updates_spec.rb": "22f290cfbe2dc1d6bb321ce782e90bb8", "spec/unit/puppet/type/apt_key_spec.rb": "986c3cf60937eb89cbf6335dc7923dc5", "templates/15update-stamp.erb": "b9de0ac9e2c9854b1bb213e362dc4e41", "templates/_conf_header.erb": "6f3077f2eabd3e929a44d55bc1c5446e", "templates/_header.erb": "9300ac105fe777787ac9e793b8df8d25", "templates/conf.erb": "b4bc626b0d998cd681ee6b8c507c0d1d", "templates/pin.pref.erb": "c3885c6816db46cf66e3a9bf57973c61", "templates/proxy.erb": "3d0f7b88020d8a29bafc690e05ca69d6", "templates/source.list.erb": "db4d349a11d19cca0828d7fd95fae1fe" }puppetlabs-apt-2.2.0/CONTRIBUTING.md000644 000766 000024 00000017435 12602537170 017161 0ustar00bmjenstaff000000 000000 Checklist (and a short version for the impatient) ================================================= * Commits: - Make commits of logical units. - Check for unnecessary whitespace with "git diff --check" before committing. - Commit using Unix line endings (check the settings around "crlf" in git-config(1)). - Do not check in commented out code or unneeded files. - The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. - Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". - The body should provide a meaningful commit message, which: - uses the imperative, present tense: "change", not "changed" or "changes". - includes motivation for the change, and contrasts its implementation with the previous behavior. - Make sure that you have tests for the bug you are fixing, or feature you are adding. - Make sure the test suites passes after your commit: `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - When introducing a new feature, make sure it is properly documented in the README.md * Submission: * Pre-requisites: - 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. * Preferred method: - Fork the repository on GitHub. - Push your changes to a topic branch in your fork of the repository. (the format ticket/1234-short_description_of_change is usually preferred for this project). - Submit a pull request to the repository in the puppetlabs organization. The long version ================ 1. Make separate commits for logically separate changes. Please break your commits down into logically consistent units which include new or changed tests relevant to the rest of the change. The goal of doing this is to make the diff easier to read for whoever is reviewing your code. In general, the easier your diff is to read, the more likely someone will be happy to review it and get it into the code base. If you are going to refactor a piece of code, please do so as a separate commit from your feature or bug fix changes. We also really appreciate changes that include tests to make sure the bug is not re-introduced, and that the feature is not accidentally broken. Describe the technical detail of the change(s). If your description starts to get too long, that is a good sign that you probably need to split up your commit into more finely grained pieces. Commits which plainly describe the things which help reviewers check the patch and future developers understand the code are much more likely to be merged in with a minimum of bike-shedding or requested changes. Ideally, the commit message would include information, and be in a form suitable for inclusion in the release notes for the version of Puppet that includes them. Please also check that you are not introducing any trailing whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of directly on "master". It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. GitHub has some pretty good [general documentation](http://help.github.com/) on using their site. They also have documentation on [creating pull requests](http://help.github.com/send-pull-requests/). In general, after pushing your topic branch up to your repository on GitHub, you can switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request. 3. Update the related GitHub issue. If there is a GitHub issue associated with the change you submitted, then you should update the ticket to include the location of your branch, along with any other commentary you may wish to make. Testing ======= Getting Started --------------- Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby package manager such as [bundler](http://bundler.io/) what Ruby packages, or Gems, are required to build, develop, and test this software. Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, then use it to install all dependencies needed for this project, by running ```shell % bundle install Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Using rake (10.1.0) Using builder (3.2.2) -- 8><-- many more --><8 -- Using rspec-system-puppet (2.2.0) Using serverspec (0.6.3) Using rspec-system-serverspec (1.0.0) Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. ``` NOTE some systems may require you to run this command with sudo. If you already have those gems installed, make sure they are up-to-date: ```shell % bundle update ``` With all dependencies in place and up-to-date we can now run the tests: ```shell % rake spec ``` This will execute all the [rspec tests](http://rspec-puppet.com/) tests under [spec/defines](./spec/defines), [spec/classes](./spec/classes), and so on. rspec tests may have the same kind of dependencies as the module they are testing. While the module defines in its [Modulefile](./Modulefile), rspec tests define them in [.fixtures.yml](./fixtures.yml). Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) tests. These tests spin up a virtual machine under [VirtualBox](https://www.virtualbox.org/)) with, controlling it with [Vagrant](http://www.vagrantup.com/) to actually simulate scripted test scenarios. In order to run these, you will need both of those tools installed on your system. You can run them by issuing the following command ```shell % rake spec_clean % rspec spec/acceptance ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) and then run all the tests under [spec/acceptance](./spec/acceptance). Writing Tests ------------- XXX getting started writing tests. If you have commit access to the repository =========================================== Even if you have commit access to the repository, you will still need to go through the process above, and have someone else review and merge in your changes. The rule is that all changes must be reviewed by a developer on the project (that did not write the code) to ensure that all changes go through a code review process. Having someone other than the author of the topic branch recorded as performing the merge is the record that they performed the code review. Additional Resources ==================== * [Getting additional help](http://puppetlabs.com/community/get-help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Patchwork](https://patchwork.puppetlabs.com) * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) puppetlabs-apt-2.2.0/examples/000755 000766 000024 00000000000 12602537570 016540 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/Gemfile000644 000766 000024 00000002562 12602537170 016216 0ustar00bmjenstaff000000 000000 source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git:[^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :development, :unit_tests do gem 'rspec-puppet', '~> 2.1', :require => false gem 'rspec-core', '3.1.7', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false end group :system_tests do if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else gem 'facter', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false else gem 'puppet', :require => false end # vim:ft=ruby puppetlabs-apt-2.2.0/lib/000755 000766 000024 00000000000 12602537570 015470 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/LICENSE000644 000766 000024 00000003117 12602537170 015725 0ustar00bmjenstaff000000 000000 Copyright (c) 2011 Evolving Web Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Copyright 2014 Puppet Labs 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 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. puppetlabs-apt-2.2.0/manifests/000755 000766 000024 00000000000 12602537570 016713 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/metadata.json000644 000766 000024 00000001720 12602537570 017375 0ustar00bmjenstaff000000 000000 { "name": "puppetlabs-apt", "version": "2.2.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "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"} ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.3.0 < 2015.3.0" }, { "name": "puppet", "version_requirement": ">= 3.0.0 < 5.0.0" } ] } puppetlabs-apt-2.2.0/Rakefile000644 000766 000024 00000000766 12602537170 016374 0ustar00bmjenstaff000000 000000 require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] puppetlabs-apt-2.2.0/README.md000644 000766 000024 00000063423 12602537170 016205 0ustar00bmjenstaff000000 000000 # apt #### Table of Contents 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) 3. [Setup - The basics of getting started with apt](#setup) * [What apt affects](#what-apt-affects) * [Beginning with apt](#beginning-with-apt) 4. [Usage - Configuration options and additional functionality](#usage) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) * [Classes](#classes) * [Defines](#defines) * [Types](#types) * [Facts](#facts) 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Development - Guide for contributing to the module](#development) ## Overview The apt module lets you use Puppet to manage Apt sources, keys, and other configuration options. ## Module Description Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. **Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. ## Setup ### What apt affects * Your system's `preferences` file and `preferences.d` directory * Your system's `sources.list` file and `sources.list.d` directory * System repositories * Authentication keys **Note:** This module offers `purge` parameters which, if set to 'true', **destroy** any configuration on the node's `sources.list(.d)` and `preferences(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. ### Beginning with apt To use the apt module with default parameters, declare the `apt` class. ~~~puppet include apt ~~~ **Note:** The main `apt` class is required by all other classes, types, and defines in this module. You must declare it whenever you use the module. ## Usage ### Add GPG keys **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: ~~~puppet apt::key { 'puppetlabs': id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', server => 'pgp.mit.edu', options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', } ~~~ ### Prioritize backports ~~~puppet class { 'apt::backports': pin => 500, } ~~~ By default, the `apt::backports` class drops a pin file for backports, pinning it to a priority of 200. This is lower than the normal default of 500, so packages with `ensure => latest` don't get upgraded from backports without your explicit permission. If you raise the priority through the `pin` parameter to 500, normal policy goes into effect and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. ### Update the list of packages By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': ~~~puppet class { 'apt': update => { frequency => 'daily', }, } ~~~ ### Pin a specific release ~~~puppet apt::pin { 'karmic': priority => 700 } apt::pin { 'karmic-updates': priority => 700 } apt::pin { 'karmic-security': priority => 700 } ~~~ You can also specify more complex pins using distribution properties: ~~~puppet apt::pin { 'stable': priority => -10, originator => 'Debian', release_version => '3.0', component => 'main', label => 'Debian' } ~~~ To pin multiple packages, pass them to the `packages` parameter as an array or a space-delimited string. ### Add a PPA (Personal Package Archive) repository ~~~puppet apt::ppa { 'ppa:drizzle-developers/ppa': } ~~~ ### Add an Apt source to `/etc/apt/sources.list.d/` ~~~puppet apt::source { 'debian_unstable': comment => 'This is the iWeb Debian unstable mirror', location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', pin => '-10', key => { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'server' => 'subkeys.pgp.net', }, include => { 'src' => true, 'deb' => true, }, } ~~~ To use the Puppet Labs Apt repository as a source: ~~~puppet apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', key => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu', }, }, ~~~ ### Configure Apt from Hiera ~~~yaml apt::sources: 'debian_unstable': location: 'http://debian.mirror.iweb.ca/debian/' release: 'unstable' repos: 'main contrib non-free' key: id: '9AA38DCD55BE302B' server: 'subkeys.pgp.net' pin: '-10' include: src: true deb: true 'puppetlabs': location: 'http://apt.puppetlabs.com' repos: 'main' key: id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' server: 'pgp.mit.edu' ~~~ ## Reference ### Classes #### Public Classes * [`apt`](#class-apt) * [`apt::backports`](#class-aptbackports) #### Private Classes * `apt::params`: Provides defaults for the apt module parameters. * `apt::update`: Updates the list of available packages using `apt-get update`. ### Defines * [`apt::conf`](#define-aptconf) * [`apt::key`](#define-aptkey) * [`apt::pin`](#define-aptpin) * [`apt::ppa`](#define-aptppa) * [`apt::setting`](#define-aptsetting) * [`apt::source`](#define-aptsource) ### Types * [`apt_key`](#type-apt_key) ### Facts * `apt_updates`: The number of installed packages with available updates. * `apt_security_updates`: The number of installed packages with available security updates. * `apt_package_updates`: The names of all installed packages with available updates. In Facter 2.0 and later this data is formatted as an array; in earlier versions it is a comma-delimited string. * `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run (based on the mtime of /var/lib/apt/periodic/update-success-stamp). * `apt_reboot_required`: Determines if a reboot is necessary after updates have been installed. #### Class: `apt` Main class, includes all other classes. ##### Parameters (all optional) * `keys`: Creates new `apt::key` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `ppas`: Creates new `apt::ppa` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `proxy`: Configures Apt to connect to a proxy server. Valid options: a hash made up from the following keys: * 'host': Specifies a proxy host to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a hostname. Default: undef. * 'port': Specifies a proxy port to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a port number. Default: '8080'. * 'https': Specifies whether to enable https proxies. Valid options: 'true' and 'false'. Default: 'false'. * 'ensure': Optional parameter. Valid options: 'file', 'present', and 'absent'. Default: 'undef'. Prefer 'file' over 'present'. * `purge`: Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys: * 'sources.list': Specifies whether to purge any unmanaged entries from `sources.list`. Valid options: 'true' and 'false'. Default: 'false'. * 'sources.list.d': Specifies whether to purge any unmanaged entries from `sources.list.d`. Valid options: 'true' and 'false'. Default: 'false'. * 'preferences': Specifies whether to purge any unmanaged entries from `preferences`. Valid options: 'true' and 'false'. Default: 'false'. * 'preferences.d': Specifies whether to purge any unmanaged entries from `preferences.d`. Valid options: 'true' and 'false'. Default: 'false'. * `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `sources`: Creates new `apt::source` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `pins`: Creates new `apt::pin` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `update`: Configures various update settings. Valid options: a hash made up from the following keys: * 'frequency': Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400); 'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource `apt_update` is notified). Default: 'reluctantly'. * 'timeout': Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: 300. * 'tries': Specifies how many times to retry the update after receiving a DNS or HTTP error. Valid options: an integer. Default: 1. #### Class: `apt::backports` Manages backports. ##### Parameters (all optional on Debian and Ubuntu; all required on other operating systems, except where specified) * `key`: Specifies a key to authenticate the backports. Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Defaults: * Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' * Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5' * `location`: Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Defaults: * Debian (squeeze): 'http://httpredir.debian.org/debian-backports' * Debian (other): 'http://httpredir.debian.org/debian' * Ubuntu: 'http://archive.ubuntu.com/ubuntu' * `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. * `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. * `repos`: Specifies a component of the Apt repository containing the backports to manage. Valid options: A string containing the repos to include, used in populating the `source.list` configuration file. Defaults: * Debian: 'main contrib non-free' * Ubuntu: 'main universe multiverse restricted' #### Define: `apt::conf` Specifies a custom Apt configuration file. ##### Parameters * `content`: *Required, unless `ensure` is set to 'absent'.* Directly supplies content for the configuration file. Valid options: a string. Default: undef. * `ensure`: Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'. * `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. #### Define: `apt::key` Manages the GPG keys that Apt uses to authenticate packages. The `apt::key` define makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. ##### Parameters (all optional) * `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. * `ensure`: Specifies whether the key should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `id`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: $title. * `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. * `source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. * `server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. * `key`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: undef. **Note** This parameter is deprecated and will be removed in a future release. * `key_content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. * `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. * `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. **Note** This parameter is deprecated and will be removed in a future release. * `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. #### Define: `apt::pin` Manages Apt pins. Does not trigger an `apt-get update` run. **Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences) ##### Parameters (all optional) * `codename`: Specifies the distribution (lsbdistcodename) of the Apt repository. Valid options: a string. Default: ''. * `component`: Names the licensing component associated with the packages in the directory tree of the Release file. Valid options: a string. Default: ''. * `ensure`: Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. Default: 'present'. * `explanation`: Supplies a comment to explain the pin. Valid options: a string. Default: "${caller_module_name}: ${name}". * `label`: Names the label of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. * `order`: Determines the order in which Apt processes the pin file. Files with lower order numbers are loaded first. Valid options: an integer. Default: 50. * `origin`: Tells Apt to prefer packages from the specified server. Valid options: a string containing a hostname. Default: ''. * `originator`: Names the originator of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. * `packages`: Specifies which package(s) to pin. Valid options: a string or an array. Default: '*'. * `priority`: Sets the priority of the package. If multiple versions of a given package are available, `apt-get` installs the one with the highest priority number (subject to dependency constraints). Valid options: an integer. Default: 0. * `release`: Tells Apt to prefer packages that support the specified release. Typical values include 'stable', 'testing', and 'unstable' Valid options: a string. Default: ''. * `release_version`: Tells Apt to prefer packages that support the specified operating system release version (e.g., Debian release version 7). Valid options: a string. Default: ''. * `version`: Tells Apt to prefer a specified package version or version range. Valid options: a string. Default: ''. #### Define: `apt::ppa` Manages PPA repositories using `add-apt-repository`. Not supported on Debian. ##### Parameters (all optional, except where specified) * `ensure`: Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `options`: Supplies options to be passed to the `add-apt-repository` command. Valid options: a string. Defaults: * Lucid: undef * All others: '-y' * `package_manage`: Specifies whether Puppet should manage the package that provides `apt-add-repository`. Valid options: 'true' and 'false'. Default: 'false'. * `package_name`: Names the package that provides the `apt-add-repository` command. Valid options: a string. Defaults: * Lucid and Precise: 'python-software-properties' * Trusty, Utopic, and Vivid: 'software-properties-common' * All others: undef * `release`: *Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).* Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. Default: "$lsbdistcodename". #### Define: `apt:setting` Manages Apt configuration files. ##### Parameters * `content`: *Required, unless `source` is set.* Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid options: see the `content` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-content). Default: undef. * `ensure`: Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'. Default: 'file'. * `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. * `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first. Valid options: an integer or zero-padded integer. Default: 50. * `source`: *Required, unless `content` is set.* Specifies a source file to supply the content of the configuration file. Cannot be used in combination with `content`. Valid options: see the `source` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source). Default: undef. #### Define: `apt::source` Manages the Apt sources in `/etc/apt/sources.list.d/`. ##### Parameters (all optional, except where specified) * `allow_unsigned`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: 'false'. * `architecture`: Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option). * `comment`: Supplies a comment for adding to the Apt source file. Valid options: a string. Default: $name. * `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. * `include`: Configures include options. Valid options: a hash of available keys. Default: {}. Available keys are: * 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. * 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. * `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. * `pin`: Creates a declaration of the apt::pin define Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: undef. * `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. * `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `required_packages`: Installs packages required for this Apt source via an exec. Default: 'false'. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `key_content`: Specifies the content to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `key_server`: Specifies the server to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `key_source`: Specifies the source to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. * `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module. #### Type: `apt_key` Manages the GPG keys that Apt uses to authenticate packages. **Note:** In most cases, we recommend using the `apt::key` define. It makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. ##### Parameters (all optional) * `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Cannot be used in combination with `source`. Valid options: a string. Default: undef. * `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. * `server`: Specifies a keyserver to provide Puppet's GPG key. Valid options: a string containing a domain name or a full URL. Default: 'keyserver.ubuntu.com'. * `source`: Specifies the location of an existing GPG key file to copy. Cannot be used in combination with `content`. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. ## Limitations This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.04, 12.04, and 14.04. Testing on other platforms has been light and cannot be guaranteed. ### Adding new sources or PPAs If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior). ~~~puppet Class['apt::update'] -> Package<| |> ~~~ ## Development Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) puppetlabs-apt-2.2.0/spec/000755 000766 000024 00000000000 12602537570 015654 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/templates/000755 000766 000024 00000000000 12602537570 016720 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/templates/15update-stamp.erb000644 000766 000024 00000000154 12602537170 022160 0ustar00bmjenstaff000000 000000 APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";}; puppetlabs-apt-2.2.0/templates/_conf_header.erb000644 000766 000024 00000000060 12602537170 021776 0ustar00bmjenstaff000000 000000 // This file is managed by Puppet. DO NOT EDIT. puppetlabs-apt-2.2.0/templates/_header.erb000644 000766 000024 00000000057 12602537170 020777 0ustar00bmjenstaff000000 000000 # This file is managed by Puppet. DO NOT EDIT. puppetlabs-apt-2.2.0/templates/conf.erb000644 000766 000024 00000000021 12602537170 020324 0ustar00bmjenstaff000000 000000 <%= @content -%> puppetlabs-apt-2.2.0/templates/pin.pref.erb000644 000766 000024 00000001317 12602537170 021131 0ustar00bmjenstaff000000 000000 <%- @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 %> puppetlabs-apt-2.2.0/templates/proxy.erb000644 000766 000024 00000000305 12602537170 020565 0ustar00bmjenstaff000000 000000 Acquire::http::proxy "http://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; <%- if @_proxy['https'] %> Acquire::https::proxy "https://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; <%- end -%> puppetlabs-apt-2.2.0/templates/source.list.erb000644 000766 000024 00000001036 12602537170 021660 0ustar00bmjenstaff000000 000000 # <%= @comment %> <%- if @_include['deb'] then -%> deb <%- if @architecture or @_allow_unsigned -%> [<%- if @architecture %>arch=<%= @architecture %> <% 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 @_allow_unsigned %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @_release %> <%= @repos %> <%- end -%> puppetlabs-apt-2.2.0/spec/acceptance/000755 000766 000024 00000000000 12602537570 017742 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/classes/000755 000766 000024 00000000000 12602537570 017311 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/defines/000755 000766 000024 00000000000 12602537570 017271 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/spec.opts000644 000766 000024 00000000057 12602537170 017513 0ustar00bmjenstaff000000 000000 --format s --colour --loadby mtime --backtrace puppetlabs-apt-2.2.0/spec/spec_helper.rb000644 000766 000024 00000000064 12602537170 020466 0ustar00bmjenstaff000000 000000 require 'puppetlabs_spec_helper/module_spec_helper' puppetlabs-apt-2.2.0/spec/spec_helper_acceptance.rb000644 000766 000024 00000001315 12602537170 022634 0ustar00bmjenstaff000000 000000 require 'beaker-rspec' require 'beaker/puppet_install_helper' run_puppet_install_helper UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris'] RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) # 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 puppetlabs-apt-2.2.0/spec/unit/000755 000766 000024 00000000000 12602537570 016633 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/unit/facter/000755 000766 000024 00000000000 12602537570 020077 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/unit/puppet/000755 000766 000024 00000000000 12602537570 020150 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/unit/puppet/type/000755 000766 000024 00000000000 12602537570 021131 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/unit/puppet/type/apt_key_spec.rb000644 000766 000024 00000011645 12602537170 024127 0ustar00bmjenstaff000000 000000 require 'spec_helper' require 'puppet' describe Puppet::Type::type(:apt_key) do context 'only namevar 32bit key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30' )} it 'id is set' do expect(resource[:id]).to eq '4BD6EC30' end it 'name is set to id' do expect(resource[:name]).to eq '4BD6EC30' end it 'keyserver is default' do expect(resource[:server]).to eq :'keyserver.ubuntu.com' end it 'source is not set' do expect(resource[:source]).to eq nil end it 'content is not set' do expect(resource[:content]).to eq nil end end context 'with a lowercase 32bit key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4bd6ec30' )} it 'id is set' do expect(resource[:id]).to eq '4BD6EC30' end end context 'with a 64bit key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => 'FFFFFFFF4BD6EC30' )} it 'id is set' do expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end context 'with a 0x formatted key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '0x4BD6EC30' )} it 'id is set' do expect(resource[:id]).to eq '4BD6EC30' end end context 'with a 0x formatted lowercase key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '0x4bd6ec30' )} it 'id is set' do expect(resource[:id]).to eq '4BD6EC30' end end context 'with a 0x formatted 64bit key id' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '0xFFFFFFFF4BD6EC30' )} it 'id is set' do expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end context 'with source' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'http://apt.puppetlabs.com/pubkey.gpg' )} it 'source is set to the URL' do expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end context 'with content' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :content => 'http://apt.puppetlabs.com/pubkey.gpg' )} it 'content is set to the string' do expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end context 'with keyserver' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :server => 'http://keyring.debian.org' )} it 'keyserver is set to Debian' do expect(resource[:server]).to eq 'http://keyring.debian.org' end end context 'validation' do it 'raises an error if content and source are set' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'http://apt.puppetlabs.com/pubkey.gpg', :content => 'Completely invalid as a GPG key' )}.to raise_error(/content and source are mutually exclusive/) end it 'raises an error if a weird length key is used' do expect { Puppet::Type.type(:apt_key).new( :id => 'F4BD6EC30', :source => 'http://apt.puppetlabs.com/pubkey.gpg', :content => 'Completely invalid as a GPG key' )}.to raise_error(/Valid values match/) end it 'raises an error when an invalid URI scheme is used in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'hkp://pgp.mit.edu' )}.to raise_error(/Valid values match/) end it 'allows the http URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'http://pgp.mit.edu' )}.to_not raise_error end it 'allows the https URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'https://pgp.mit.edu' )}.to_not raise_error end it 'allows the https URI with username and password' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'https://testme:Password2@pgp.mit.edu' )}.to_not raise_error end it 'allows the ftp URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'ftp://pgp.mit.edu' )}.to_not raise_error end it 'allows an absolute path in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => '/path/to/a/file' )}.to_not raise_error end it 'allows 5-digit ports' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :source => 'http://pgp.mit.edu:12345/key' )}.to_not raise_error end it 'allows 5-digit ports when using key servers' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', :server => 'http://pgp.mit.edu:12345' )}.to_not raise_error end end end puppetlabs-apt-2.2.0/spec/unit/facter/apt_has_updates_spec.rb000644 000766 000024 00000004367 12602537170 024610 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_has_updates fact' do subject { Facter.fact(:apt_has_updates).value } after(:each) { Facter.clear } describe 'on non-Debian distro' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat' } it { is_expected.to be_nil } end describe 'on Debian based distro missing update-notifier-common' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns false } it { is_expected.to be_nil } end describe 'on Debian based distro with broken packages' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Error: BrokenCount > 0" } it { is_expected.to be_nil } end describe 'on Debian based distro with unknown error with semicolons' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Unknown Error: 'This error contains something that could be parsed like 4;3' (10)" } it { is_expected.to be_nil } end describe 'on Debian based distro' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3" } it { is_expected.to be true } end end puppetlabs-apt-2.2.0/spec/unit/facter/apt_package_updates_spec.rb000644 000766 000024 00000002174 12602537170 025422 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_package_updates fact' do subject { Facter.fact(:apt_package_updates).value } after(:each) { Facter.clear } describe 'when apt has no updates' do before { Facter.fact(:apt_has_updates).stubs(:value).returns false } it { is_expected.to be nil } end describe 'when apt has updates' do before { Facter.fact(:osfamily).stubs(:value).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "1;2" Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>&1').returns "puppet-common\nlinux-generic\nlinux-image-generic" } it { if Facter.version < '2.0.0' is_expected.to eq('puppet-common,linux-generic,linux-image-generic') else is_expected.to eq(['puppet-common', 'linux-generic', 'linux-image-generic']) end } end end puppetlabs-apt-2.2.0/spec/unit/facter/apt_reboot_required_spec.rb000644 000766 000024 00000001361 12602537170 025471 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_reboot_required fact' do subject { Facter.fact(:apt_reboot_required).value } after(:each) { Facter.clear } describe 'if a reboot is required' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:file?).returns true File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns true } it { is_expected.to eq true } end describe 'if a reboot is not required' do before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:file?).returns true File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns false } it { is_expected.to eq false } end end puppetlabs-apt-2.2.0/spec/unit/facter/apt_security_updates_spec.rb000644 000766 000024 00000001444 12602537170 025675 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_security_updates fact' do subject { Facter.fact(:apt_security_updates).value } after(:each) { Facter.clear } describe 'when apt has no updates' do before { Facter.fact(:apt_has_updates).stubs(:value).returns false } it { is_expected.to be nil } end describe 'when apt has security updates' do before { Facter.fact(:osfamily).stubs(:value).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } it { is_expected.to eq(7) } end end puppetlabs-apt-2.2.0/spec/unit/facter/apt_update_last_success_spec.rb000644 000766 000024 00000001454 12602537170 026337 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_update_last_success fact' do subject { Facter.fact(:apt_update_last_success).value } 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 is_expected.to eq(-1) end end describe 'on Debian based distro which has created the update-success-stamp' do before { 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 end puppetlabs-apt-2.2.0/spec/unit/facter/apt_updates_spec.rb000644 000766 000024 00000001412 12602537170 023741 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt_updates fact' do subject { Facter.fact(:apt_updates).value } after(:each) { Facter.clear } describe 'when apt has no updates' do before { Facter.fact(:apt_has_updates).stubs(:value).returns false } it { is_expected.to be nil } end describe 'when apt has updates' do before { Facter.fact(:osfamily).stubs(:value).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } it { is_expected.to eq(14) } end end puppetlabs-apt-2.2.0/spec/defines/conf_spec.rb000644 000766 000024 00000004011 12602537170 021545 0ustar00bmjenstaff000000 000000 require 'spec_helper' 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 :title do 'norecommends' end describe "when creating an apt preference" do let :default_params do { :priority => '00', :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" } end let :params do default_params end let :filename do "/etc/apt/apt.conf.d/00norecommends" end it { is_expected.to contain_file(filename).with({ 'ensure' => 'present', 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', 'group' => 'root', 'mode' => '0644', }) } context "with notify_update = true (default)" do let :params do default_params end it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) } end context "with notify_update = false" do let :params do default_params.merge({ :notify_update => false }) end it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) } end end describe "when creating a preference without content" do let :params do { :priority => '00', } end it 'fails' do expect { subject.call } .to raise_error(/pass in content/) end end describe "when removing an apt preference" do let :params do { :ensure => 'absent', :priority => '00', } end let :filename do "/etc/apt/apt.conf.d/00norecommends" end it { is_expected.to contain_file(filename).with({ 'ensure' => 'absent', 'owner' => 'root', 'group' => 'root', 'mode' => '0644', }) } end end puppetlabs-apt-2.2.0/spec/defines/key_compat_spec.rb000644 000766 000024 00000020152 12602537170 022757 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::key', :type => :define do let(:facts) { { :lsbdistid => 'Debian' } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do GPG_KEY_ID end describe 'normal operation' do describe 'default options' do it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => nil, :server => nil, :content => nil, :keyserver_options => nil, }) end it 'contains the apt_key present anchor' do should contain_anchor("apt_key #{title} present") end end describe 'title and key =>' do let :title do 'puppetlabs' end let :params do { :key => GPG_KEY_ID, } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => GPG_KEY_ID, :ensure => 'present', :source => nil, :server => nil, :content => nil, :keyserver_options => nil, }) end it 'contains the apt_key present anchor' do should contain_anchor("apt_key #{GPG_KEY_ID} present") end end describe 'ensure => absent' do let :params do { :ensure => 'absent', } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :ensure => 'absent', :source => nil, :server => nil, :content => nil, :keyserver_options => nil, }) end it 'contains the apt_key absent anchor' do should contain_anchor("apt_key #{title} absent") end end 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', } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => 'http://apt.puppetlabs.com/pubkey.gpg', :server => 'pgp.mit.edu', :content => params[:key_content], :options => 'debug', }) end it 'contains the apt_key present anchor' do should contain_anchor("apt_key #{title} present") end end context "domain with dash" do let(:params) do{ :key_server => 'p-gp.m-it.edu', } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :server => 'p-gp.m-it.edu', }) end end context "url" do let :params do { :key_server => 'hkp://pgp.mit.edu', } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu', }) end end context "url with port number" do let :params do { :key_server => 'hkp://pgp.mit.edu:80', } end it 'contains the apt_key' do should contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu:80', }) end end end describe 'validation' do context "domain begin with dash" do let(:params) do{ :key_server => '-pgp.mit.edu', } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "domain begin with dot" do let(:params) do{ :key_server => '.pgp.mit.edu', } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "domain end with dot" do let(:params) do{ :key_server => "pgp.mit.edu.", } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "exceed character url" do let :params do { :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "incorrect port number url" do let :params do { :key_server => 'hkp://pgp.mit.edu:8008080' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "incorrect protocol for url" do let :params do { :key_server => 'abc://pgp.mit.edu:80' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "missing port number url" do let :params do { :key_server => 'hkp://pgp.mit.edu:' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "url ending with a dot" do let :params do { :key_server => 'hkp://pgp.mit.edu.' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "url begin with a dash" do let(:params) do{ :key_server => "hkp://-pgp.mit.edu", } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid source' do let :params do { :key_source => 'afp://puppetlabs.com/key.gpg', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid content' do let :params do { :key_content => [], } end it 'fails' do expect { subject.call }.to raise_error(/is not a string/) end end context 'invalid server' do let :params do { :key_server => 'two bottles of rum', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid keyserver_options' do let :params do { :key_options => {}, } end it 'fails' do expect { subject.call }.to raise_error(/is not a string/) end end context 'invalid ensure' do let :params do { :ensure => 'foo', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end describe 'duplication' do context 'two apt::key resources for same key, different titles' do let :pre_condition do "apt::key { 'duplicate': key => '#{title}', }" end it 'contains two apt::key resources' do should contain_apt__key('duplicate').with({ :key => title, :ensure => 'present', }) should contain_apt__key(title).with({ :id => title, :ensure => 'present', }) end it 'contains only a single apt_key' do should contain_apt_key('duplicate').with({ :id => title, :ensure => 'present', :source => nil, :server => nil, :content => nil, :keyserver_options => nil, }) should_not contain_apt_key(title) end end context 'two apt::key resources, different ensure' do let :pre_condition do "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do expect { subject.call }.to raise_error(/already ensured as absent/) end end end end end puppetlabs-apt-2.2.0/spec/defines/key_spec.rb000644 000766 000024 00000020240 12602537170 021412 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::key' do let :pre_condition do 'class { "apt": }' end let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do GPG_KEY_ID end describe 'normal operation' do describe 'default options' do it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => nil, :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end describe 'title and key =>' do let :title do 'puppetlabs' end let :params do { :id => GPG_KEY_ID, } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => GPG_KEY_ID, :ensure => 'present', :source => nil, :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end end describe 'ensure => absent' do let :params do { :ensure => 'absent', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'absent', :source => nil, :server => 'keyserver.ubuntu.com', :content => nil, :keyserver => nil, }) end it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end end describe 'set a bunch of things!' do let :params do { :content => 'GPG key content', :source => 'http://apt.puppetlabs.com/pubkey.gpg', :server => 'pgp.mit.edu', :options => 'debug', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => 'http://apt.puppetlabs.com/pubkey.gpg', :server => 'pgp.mit.edu', :content => params[:content], :options => 'debug', }) end it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end end context "domain with dash" do let(:params) do{ :server => 'p-gp.m-it.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :server => 'p-gp.m-it.edu', }) end end context "url" do let :params do { :server => 'hkp://pgp.mit.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu', }) end end context "url with port number" do let :params do { :server => 'hkp://pgp.mit.edu:80', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu:80', }) end end end describe 'validation' do context "domain begin with dash" do let(:params) do{ :server => '-pgp.mit.edu', } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "domain begin with dot" do let(:params) do{ :server => '.pgp.mit.edu', } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "domain end with dot" do let(:params) do{ :server => "pgp.mit.edu.", } end it 'fails' do expect { subject.call } .to raise_error(/does not match/) end end context "exceed character url" do let :params do { :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "incorrect port number url" do let :params do { :server => 'hkp://pgp.mit.edu:8008080' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "incorrect protocol for url" do let :params do { :server => 'abc://pgp.mit.edu:80' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "missing port number url" do let :params do { :server => 'hkp://pgp.mit.edu:' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "url ending with a dot" do let :params do { :server => 'hkp://pgp.mit.edu.' } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context "url begin with a dash" do let(:params) do{ :server => "hkp://-pgp.mit.edu", } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid source' do let :params do { :source => 'afp://puppetlabs.com/key.gpg', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid content' do let :params do { :content => [], } end it 'fails' do expect { subject.call }.to raise_error(/is not a string/) end end context 'invalid server' do let :params do { :server => 'two bottles of rum', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end context 'invalid options' do let :params do { :options => {}, } end it 'fails' do expect { subject.call }.to raise_error(/is not a string/) end end context 'invalid ensure' do let :params do { :ensure => 'foo', } end it 'fails' do expect { subject.call }.to raise_error(/does not match/) end end describe 'duplication' do context 'two apt::key resources for same key, different titles' do let :pre_condition do "class { 'apt': } apt::key { 'duplicate': id => '#{title}', }" end it 'contains two apt::key resources' do is_expected.to contain_apt__key('duplicate').with({ :id => title, :ensure => 'present', }) is_expected.to contain_apt__key(title).with({ :id => title, :ensure => 'present', }) end it 'contains only a single apt_key' do is_expected.to contain_apt_key('duplicate').with({ :id => title, :ensure => 'present', :source => nil, :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) is_expected.not_to contain_apt_key(title) end end context 'two apt::key resources, different ensure' do let :pre_condition do "class { 'apt': } apt::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/) end end end end end puppetlabs-apt-2.2.0/spec/defines/pin_spec.rb000644 000766 000024 00000007531 12602537170 021420 0ustar00bmjenstaff000000 000000 require 'spec_helper' 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(: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', } 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 let :params do { 'packages' => 'vim', 'origin' => 'test', } 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 let :params do { 'explanation' => 'foo', 'order' => 99, 'release' => '1', 'codename' => 'bar', 'release_version' => '2', 'component' => 'baz', 'originator' => 'foobar', 'label' => 'foobaz', 'priority' => 10, } end it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } it { is_expected.to contain_apt__setting("pref-my_pin").with({ 'priority' => 99, }) } end context 'ensure absent' do let :params do { 'ensure' => 'absent' } end it { is_expected.to contain_apt__setting("pref-my_pin").with({ 'ensure' => 'absent', }) } end context 'bad characters' do let(:title) { 'such bad && wow!' } it { is_expected.to contain_apt__setting("pref-such__bad____wow_") } end describe 'validation' do context 'invalid order' do let :params do { 'order' => 'foo', } end it do expect { subject.call }.to raise_error(Puppet::Error, /Only integers are allowed/) end end context 'packages == * and version' do let :params do { 'version' => '1', } end it do expect { subject.call }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/) end end context 'packages == * and release and origin' do let :params do { 'origin' => 'test', 'release' => 'foo', } end it do expect { subject.call }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/) end end context 'specific form with release and origin' do let :params do { 'release' => 'foo', 'origin' => 'test', 'packages' => 'vim', } end it do expect { subject.call }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end context 'specific form with version and origin' do let :params do { 'version' => '1', 'origin' => 'test', 'packages' => 'vim', } end it do expect { subject.call }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end end end puppetlabs-apt-2.2.0/spec/defines/ppa_spec.rb000644 000766 000024 00000022645 12602537170 021415 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::ppa' do let :pre_condition do 'class { "apt": }' end describe 'defaults' do let :facts do { :lsbdistrelease => '11.04', :lsbdistcodename => 'natty', :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', :puppetversion => Puppet.version, } end let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to_not contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ :environment => [], :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', :user => 'root', :logoutput => 'on_failure', }) } end describe 'ppa depending on ppa, MODULES-1156' do let :pre_condition do 'class { "apt": }' end end describe 'package_name => software-properties-common' do let :pre_condition do 'class { "apt": }' end let :params do { :package_name => 'software-properties-common', :package_manage => true, } end let :facts do { :lsbdistrelease => '11.04', :lsbdistcodename => 'natty', :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', :puppetversion => Puppet.version, } end let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ 'environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', 'user' => 'root', 'logoutput' => 'on_failure', }) } it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ 'ensure' => 'file', }) } end describe 'package_manage => false' do let :pre_condition do 'class { "apt": }' end let :facts do { :lsbdistrelease => '11.04', :lsbdistcodename => 'natty', :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', :puppetversion => Puppet.version, } end let :params do { :package_manage => false, } end let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to_not contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ 'environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', 'user' => 'root', 'logoutput' => 'on_failure', }) } it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ 'ensure' => 'file', }) } end describe 'apt included, no proxy' do let :pre_condition do 'class { "apt": } apt::ppa { "ppa:foo2": } ' end let :facts do { :lsbdistrelease => '14.04', :lsbdistcodename => 'trusty', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :options => '', :package_manage => true, :require => 'Apt::Ppa[ppa:foo2]', } end let(:title) { 'ppa:foo' } it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => [], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) } end describe 'apt included, proxy host' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost" }, }' end let :facts do { :lsbdistrelease => '14.04', :lsbdistcodename => 'trusty', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { 'options' => '', 'package_manage' => true, } end let(:title) { 'ppa:foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8080'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) } end describe 'apt included, proxy host and port' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost", "port" => 8180 }, }' end let :facts do { :lsbdistrelease => '14.04', :lsbdistcodename => 'trusty', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :options => '', :package_manage => true, } end let(:title) { 'ppa:foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) } end describe 'apt included, proxy host and port and https' do let :pre_condition do 'class { "apt": proxy => { "host" => "localhost", "port" => 8180, "https" => true }, }' end let :facts do { :lsbdistrelease => '14.04', :lsbdistcodename => 'trusty', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :options => '', :package_manage => true, } end let(:title) { 'ppa:foo' } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) } end describe 'ensure absent' do let :pre_condition do 'class { "apt": }' end let :facts do { :lsbdistrelease => '14.04', :lsbdistcodename => 'trusty', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } let :params do { :ensure => 'absent' } end it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', }) } end context 'validation' do describe 'no release' do let :facts do { :lsbdistrelease => '14.04', :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodeanme => nil, :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } it do expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end describe 'not ubuntu' do let :facts do { :lsbdistrelease => '6.0.7', :lsbdistcodename => 'wheezy', :operatingsystem => 'Debian', :lsbdistid => 'debian', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } it do expect { subject.call }.to raise_error(Puppet::Error, /not currently supported on Debian/) end end end end puppetlabs-apt-2.2.0/spec/defines/setting_spec.rb000644 000766 000024 00000007522 12602537170 022307 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } describe 'when using the defaults' do context 'without source or content' do it do expect { subject.call }.to raise_error(Puppet::Error, /needs either of /) end end context 'with title=conf-teddybear ' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') } end context 'with title=pref-teddybear' do let(:title) { 'pref-teddybear' } let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') } end context 'with title=list-teddybear' do let(:title) { 'list-teddybear' } let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') } end context 'with source' do let(:params) { { :source => 'puppet:///la/die/dah' } } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', :mode => '0644', :source => "#{params[:source]}", })} end context 'with content' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', :mode => '0644', :content => "#{params[:content]}", })} end end describe 'settings requiring settings, MODULES-769' do let(:pre_condition) do 'class { "apt": } apt::setting { "list-teddybear": content => "foo" } ' end let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) } it { is_expected.to compile.with_all_deps } end describe 'when trying to pull one over' do context 'with source and content' do let(:params) { default_params.merge({ :source => 'la' }) } it do expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /) end end context 'with title=ext-teddybear' do let(:title) { 'ext-teddybear' } let(:params) { default_params } it do expect { subject.call }.to raise_error(Puppet::Error, /must start with /) 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 /) 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 /) end end end describe 'with priority=100' do let(:params) { default_params.merge({ :priority => 100 }) } it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') } end describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', })} end end puppetlabs-apt-2.2.0/spec/defines/source_compat_spec.rb000644 000766 000024 00000010547 12602537170 023476 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::source', :type => :define do GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do 'my_source' end context 'mostly defaults' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', } end let :params do { 'include_deb' => false, 'include_src' => true, 'location' => 'http://debian.mirror.iweb.ca/debian/', } end it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } end context 'no defaults' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian' } 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, } end it { is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ 'ensure' => 'present', 'priority' => '10', 'origin' => 'debian.mirror.iweb.ca', }) } 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 let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian' } end let :params do { 'include_src' => false, 'location' => 'http://debian.mirror.iweb.ca/debian/', 'trusted_source' => true, } end it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } end context 'architecture equals x86_64' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian' } end let :params do { 'location' => 'http://debian.mirror.iweb.ca/debian/', 'architecture' => 'x86_64', } end it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64 \] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } end context 'ensure => absent' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian' } end let :params do { 'ensure' => 'absent', } end it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'absent' }) } end describe 'validation' do context 'no release' do let :facts do { :lsbdistid => 'Debian', :osfamily => 'Debian' } end it do expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end end end puppetlabs-apt-2.2.0/spec/defines/source_spec.rb000644 000766 000024 00000025711 12602537170 022132 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::source' do GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :pre_condition do 'class { "apt": }' end let :title do 'my_source' end context 'defaults' do context 'without location' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end it do expect { subject.call }.to raise_error(Puppet::Error, /source entry without specifying a location/) end end context 'with location' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :location => 'hello.there', } } it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/) } end end describe 'no defaults' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end context 'with complex pin' do let :params do { :location => 'hello.there', :pin => { 'release' => 'wishwash', 'explanation' => 'wishwash', 'priority' => 1001, }, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/hello.there wheezy main\n/) } it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')} it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', :priority => 1001, :explanation => 'wishwash', :release => 'wishwash', }) } end context 'with simple key' do let :params do { :comment => 'foo', :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', :allow_unsigned => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', :priority => '10', :origin => 'debian.mirror.iweb.ca', }) } 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, }) } end context 'with complex key' do let :params do { :comment => 'foo', :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',}, :pin => '10', :architecture => 'x86_64', :allow_unsigned => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', :priority => '10', :origin => 'debian.mirror.iweb.ca', }) } 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, :server => 'pgp.mit.edu', :content => 'GPG key content', :source => 'http://apt.puppetlabs.com/pubkey.gpg', }) } end context 'with simple key' do let :params do { :comment => 'foo', :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', :allow_unsigned => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', :priority => '10', :origin => 'debian.mirror.iweb.ca', }) } 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, }) } end end context 'allow_unsigned true' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :allow_unsigned => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/) } end context 'architecture equals x86_64' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :include => {'deb' => false, 'src' => true,}, :architecture => 'x86_64', } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/) } end context 'include_src => true' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :include_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/) } end context 'include_deb => false' do let :facts do { :lsbdistid => 'debian', :lsbdistcodename => 'wheezy', :osfamily => 'debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :include_deb => false, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', }).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_src => true and include_deb => false' do let :facts do { :lsbdistid => 'debian', :lsbdistcodename => 'wheezy', :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', }).with_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 let :facts do { :lsbdistid => 'debian', :lsbdistcodename => 'wheezy', :osfamily => 'debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :include_deb => true, :include_src => false, :include => { 'deb' => false, '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/) } it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } end context 'ensure => absent' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :ensure => 'absent', } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'absent' }) } end describe 'validation' do context 'no release' do let :facts do { :lsbdistid => 'Debian', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :location => 'hello.there', } } it do expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end context 'invalid pin' do let :facts do { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', :puppetversion => Puppet.version, } end let :params do { :location => 'hello.there', :pin => true, } end it do expect { subject.call }.to raise_error(Puppet::Error, /invalid value for pin/) end end end end puppetlabs-apt-2.2.0/spec/classes/apt_backports_spec.rb000644 000766 000024 00000017313 12602537170 023505 0ustar00bmjenstaff000000 000000 #!/usr/bin/env rspec require 'spec_helper' describe 'apt::backports', :type => :class do let (:pre_condition) { "class{ '::apt': }" } describe 'debian/ubuntu tests' do context 'defaults on deb' do let(:facts) do { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ :location => 'http://httpredir.debian.org/debian', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'wheezy-backports', :pin => { 'priority' => 200, 'release' => 'wheezy-backports' }, }) } end context 'defaults on squeeze' do let(:facts) do { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'squeeze', :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ :location => 'http://httpredir.debian.org/debian-backports', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'squeeze-backports', :pin => { 'priority' => 200, 'release' => 'squeeze-backports' }, }) } end context 'defaults on ubuntu' do let(:facts) do { :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ :location => 'http://archive.ubuntu.com/ubuntu', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', :repos => 'main universe multiverse restricted', :release => 'trusty-backports', :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, }) } end context 'set everything' do let(:facts) do { :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', :puppetversion => Puppet.version, } end let(:params) do { :location => 'http://archive.ubuntu.com/ubuntu-test', :release => 'vivid', :repos => 'main', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :pin => '90', } end it { is_expected.to contain_apt__source('backports').with({ :location => 'http://archive.ubuntu.com/ubuntu-test', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main', :release => 'vivid', :pin => { 'priority' => 90, 'release' => 'vivid' }, }) } end context 'set things with hashes' do let(:facts) do { :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', :puppetversion => Puppet.version, } end let(:params) do { :key => { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', }, :pin => { 'priority' => '90', }, } end it { is_expected.to contain_apt__source('backports').with({ :key => { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, :pin => { 'priority' => '90' }, }) } end end describe 'mint tests' do let(:facts) do { :lsbdistid => 'linuxmint', :osfamily => 'Debian', :lsbdistcodename => 'qiana', :puppetversion => Puppet.version, } end context 'sets all the needed things' do let(:params) do { :location => 'http://archive.ubuntu.com/ubuntu', :release => 'trusty-backports', :repos => 'main universe multiverse restricted', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it { is_expected.to contain_apt__source('backports').with({ :location => 'http://archive.ubuntu.com/ubuntu', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', :repos => 'main universe multiverse restricted', :release => 'trusty-backports', :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, }) } end context 'missing location' do let(:params) do { :release => 'trusty-backports', :repos => 'main universe multiverse restricted', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do expect { subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end context 'missing release' do let(:params) do { :location => 'http://archive.ubuntu.com/ubuntu', :repos => 'main universe multiverse restricted', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do expect { subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end context 'missing repos' do let(:params) do { :location => 'http://archive.ubuntu.com/ubuntu', :release => 'trusty-backports', :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', } end it do expect { subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end context 'missing key' do let(:params) do { :location => 'http://archive.ubuntu.com/ubuntu', :release => 'trusty-backports', :repos => 'main universe multiverse restricted', } end it do expect { subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end end describe 'validation' do let(:facts) do { :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', :puppetversion => Puppet.version, } end context 'invalid location' do let(:params) do { :location => true } end it do expect { subject.call }.to raise_error(Puppet::Error, /is not a string/) end end context 'invalid release' do let(:params) do { :release => true } end it do expect { subject.call }.to raise_error(Puppet::Error, /is not a string/) end end context 'invalid repos' do let(:params) do { :repos => true } end it do expect { subject.call }.to raise_error(Puppet::Error, /is not a string/) end end context 'invalid key' do let(:params) do { :key => true } end it do expect { subject.call }.to raise_error(Puppet::Error, /is not a string/) end end context 'invalid pin' do let(:params) do { :pin => true } end it do expect { subject.call }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/) end end end end puppetlabs-apt-2.2.0/spec/classes/apt_spec.rb000644 000766 000024 00000022406 12602537170 021434 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} } context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'file', :path => '/etc/apt/sources.list', :owner => 'root', :group => 'root', :mode => '0644', :notify => 'Class[Apt::Update]', })} it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'directory', :path => '/etc/apt/sources.list.d', :owner => 'root', :group => 'root', :mode => '0644', :purge => false, :recurse => false, :notify => 'Class[Apt::Update]', })} it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'file', :path => '/etc/apt/preferences', :owner => 'root', :group => 'root', :mode => '0644', :notify => 'Class[Apt::Update]', })} it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'directory', :path => '/etc/apt/preferences.d', :owner => 'root', :group => 'root', :mode => '0644', :purge => false, :recurse => false, :notify => 'Class[Apt::Update]', })} it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ :group => 'root', :mode => '0644', :owner => 'root', }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/) end it { is_expected.to contain_exec('apt_update').with({ :refreshonly => 'true', })} it { is_expected.not_to contain_apt__setting('conf-proxy') } end describe 'proxy=' do context 'host=localhost' do let(:params) { { :proxy => { 'host' => 'localhost'} } } it { is_expected.to contain_apt__setting('conf-proxy').with({ :priority => '01', }).with_content( /Acquire::http::proxy "http:\/\/localhost:8080\/";/ ).without_content( /Acquire::https::proxy/ )} end context 'host=localhost and port=8180' do let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } } it { is_expected.to contain_apt__setting('conf-proxy').with({ :priority => '01', }).with_content( /Acquire::http::proxy "http:\/\/localhost:8180\/";/ ).without_content( /Acquire::https::proxy/ )} end context 'host=localhost and https=true' do let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } } it { is_expected.to contain_apt__setting('conf-proxy').with({ :priority => '01', }).with_content( /Acquire::http::proxy "http:\/\/localhost:8080\/";/ ).with_content( /Acquire::https::proxy "https:\/\/localhost:8080\/";/ )} end context 'ensure=absent' do let(:params) { { :proxy => { 'ensure' => 'absent'} } } it { is_expected.to contain_apt__setting('conf-proxy').with({ :ensure => 'absent', :priority => '01', })} end end context 'lots of non-defaults' do let :params do { :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, :purge => { 'sources.list' => false, 'sources.list.d' => false, 'preferences' => false, 'preferences.d' => false, }, } end it { is_expected.to contain_file('sources.list').with({ :content => nil, })} it { is_expected.to contain_file('sources.list.d').with({ :purge => false, :recurse => false, })} it { is_expected.to contain_file('preferences').with({ :ensure => 'file', })} it { is_expected.to contain_file('preferences.d').with({ :purge => false, :recurse => false, })} it { is_expected.to contain_exec('apt_update').with({ :refreshonly => false, :timeout => 1, :tries => 3, })} end context 'with sources defined on valid osfamily' do let :facts do { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :sources => { 'debian_unstable' => { 'location' => 'http://debian.mirror.iweb.ca/debian/', 'release' => 'unstable', 'repos' => 'main contrib non-free', 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, 'pin' => '-10', 'include' => {'src' => true,}, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' }, } } } } it { is_expected.to contain_apt__setting('list-debian_unstable').with({ :ensure => 'present', }) } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } it { is_expected.to contain_apt__setting('list-puppetlabs').with({ :ensure => 'present', }) } it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } end context 'with keys defined on valid osfamily' do let :facts do { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :keys => { '55BE302B' => { 'server' => 'subkeys.pgp.net', }, '4BD6EC30' => { 'server' => 'pgp.mit.edu', } } } } it { is_expected.to contain_apt__key('55BE302B').with({ :server => 'subkeys.pgp.net', })} it { is_expected.to contain_apt__key('4BD6EC30').with({ :server => 'pgp.mit.edu', })} end context 'with ppas defined on valid osfamily' do let :facts do { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'ubuntu', :puppetversion => Puppet.version, } end let(:params) { { :ppas => { 'ppa:drizzle-developers/ppa' => {}, 'ppa:nginx/stable' => {}, } } } it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')} it { is_expected.to contain_apt__ppa('ppa:nginx/stable')} end context 'with settings defined on valid osfamily' do let :facts do { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :settings => { 'conf-banana' => { 'content' => 'banana' }, 'pref-banana' => { 'content' => 'banana' }, } } } it { is_expected.to contain_apt__setting('conf-banana')} it { is_expected.to contain_apt__setting('pref-banana')} end context 'with pins defined on valid osfamily' do let :facts do { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, } end let(:params) { { :pins => { 'stable' => { 'priority' => 600, 'order' => 50 }, 'testing' => { 'priority' => 700, 'order' => 100 }, } } } it { is_expected.to contain_apt__pin('stable') } it { is_expected.to contain_apt__pin('testing') } end describe 'failing tests' do context "purge['sources.list']=>'banana'" do let(:params) { { :purge => { 'sources.list' => 'banana' }, } } it do expect { subject.call }.to raise_error(Puppet::Error) end end context "purge['sources.list.d']=>'banana'" do let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } } it do expect { subject.call }.to raise_error(Puppet::Error) end end context "purge['preferences']=>'banana'" do let(:params) { { :purge => { 'preferences' => 'banana' }, } } it do expect { subject.call }.to raise_error(Puppet::Error) end end context "purge['preferences.d']=>'banana'" do let(:params) { { :purge => { 'preferences.d' => 'banana' }, } } it do expect { subject.call }.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 puppetlabs-apt-2.2.0/spec/classes/apt_update_spec.rb000644 000766 000024 00000011257 12602537170 023000 0ustar00bmjenstaff000000 000000 #!/usr/bin/env rspec 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| 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' },}" } 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}) end end end context 'when $::apt_update_last_success is nil' do let(:facts) { { :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 is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end 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| 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' => '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) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end end context 'when $::apt_update_last_success is nil' do let(:facts) { { :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) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end end ['daily','weekly'].each do |update_frequency| 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 (: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 is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end 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 (: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) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) 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 (: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 is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end end end puppetlabs-apt-2.2.0/spec/classes/params_spec.rb000644 000766 000024 00000001625 12602537170 022133 0ustar00bmjenstaff000000 000000 require 'spec_helper' describe 'apt::params', :type => :class do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:title) { 'my_package' } it { is_expected.to contain_apt__params } # 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 puppetlabs-apt-2.2.0/spec/acceptance/apt_key_provider_spec.rb000644 000766 000024 00000071213 12602537170 024647 0ustar00bmjenstaff000000 000000 require 'spec_helper_acceptance' PUPPETLABS_GPG_KEY_SHORT_ID = '4BD6EC30' PUPPETLABS_GPG_KEY_LONG_ID = '1054B7A24BD6EC30' PUPPETLABS_GPG_KEY_FINGERPRINT = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' PUPPETLABS_APT_URL = 'apt.puppetlabs.com' PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' CENTOS_GPG_KEY_SHORT_ID = 'C105B9DE' CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE' CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE' CENTOS_REPO_URL = 'ftp.cvut.cz/centos' CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' SHOULD_NEVER_EXIST_ID = '4BD6EC30' KEY_CHECK_COMMAND = "apt-key adv --list-keys --with-colons --fingerprint | grep " PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}" CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}" describe 'apt_key' do before(:each) do # Delete twice to make sure everything is cleaned # up after the short key collision shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", :acceptable_exit_codes => [0,1,2]) shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", :acceptable_exit_codes => [0,1,2]) end describe 'default options' do key_versions = { '32bit key id' => '4BD6EC30', '64bit key id' => '1054B7A24BD6EC30', '160bit key fingerprint' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', '32bit lowercase key id' => '4bd6ec30', '64bit lowercase key id' => '1054b7a24bd6ec30', '160bit lowercase key fingerprint' => '47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', '0x formatted 32bit key id' => '0x4BD6EC30', '0x formatted 64bit key id' => '0x1054B7A24BD6EC30', '0x formatted 160bit key fingerprint' => '0x47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', '0x formatted 32bit lowercase key id' => '0x4bd6ec30', '0x formatted 64bit lowercase key id' => '0x1054b7a24bd6ec30', '0x formatted 160bit lowercase key fingerprint' => '0x47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', } key_versions.each do |key, value| context "#{key}" do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{value}', ensure => 'present', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end end context 'invalid length key id' do it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '4B7A24BD6EC30', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/Valid values match/) end end end end describe 'ensure =>' do context 'absent' do it 'is removed' do pp = <<-EOS apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } EOS # Install the key first shell("apt-key adv --keyserver keyserver.ubuntu.com \ --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") shell(CENTOS_KEY_CHECK_COMMAND) # Time to remove it using Puppet apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(CENTOS_KEY_CHECK_COMMAND, :acceptable_exit_codes => [1]) shell("apt-key adv --keyserver keyserver.ubuntu.com \ --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") end end context 'absent, added with long key', :unless => (fact('operatingsystem') == 'Debian' and fact('operatingsystemmajrelease') == '6') do it 'is removed' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'absent', } EOS # Install the key first shell("apt-key adv --keyserver keyserver.ubuntu.com \ --recv-keys #{PUPPETLABS_GPG_KEY_LONG_ID}") shell(PUPPETLABS_KEY_CHECK_COMMAND) # Time to remove it using Puppet apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND, :acceptable_exit_codes => [1]) end end end describe 'content =>' do context 'puppetlabs gpg key' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', content => "-----B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OlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= =a34C -----END PGP PUBLIC KEY BLOCK-----", } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'multiple keys' do it 'runs without errors' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', content => "-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: GPGTools - http://gpgtools.org mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLF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gRbiRMv7rBAx5Q8rbYiym8im+5XNUDy2 ZTQcCD53HcBLvKX6RJ4ByYawKaQqMa27WK/YWVmFXqVDVk12iKrQW6zktDdGInnD +f0rRH7c/7F/QuBR6Y4Zkso0CuVMNsmxv0E+7Zk0z4dWalzQuXpN7OXcZ8Gp =Gl+v -----END PGP PUBLIC KEY BLOCK-----", } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'bogus key' do it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', content => 'For posterity: such content, much bogus, wow', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/no valid OpenPGP data found/) end end end end describe 'server =>' do context 'pgp.mit.edu' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'pgp.mit.edu', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'hkp://pgp.mit.edu:80' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', server => 'hkp://pgp.mit.edu:80', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context 'nonexistant.key.server' do it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'nonexistant.key.server', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/) end end end context 'key server start with dot' do it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => '.pgp.key.server', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/Invalid value \".pgp.key.server\"/) end end end end describe 'source =>' do context 'http://' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/404 Not Found/) end end it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/could not resolve/) end end end context 'ftp://' do before(:each) do shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", :acceptable_exit_codes => [0,1,2]) end it 'works' do pp = <<-EOS apt_key { 'CentOS 6': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(CENTOS_KEY_CHECK_COMMAND) end it 'fails with a 550' do pp = <<-EOS apt_key { 'CentOS 6': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/550 Failed to open/) end end it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/could not resolve/) end end end context 'https://' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/404 Not Found/) end end it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/could not resolve/) end end end context '/path/that/exists' do before(:each) do shell("curl -o /tmp/puppetlabs-pubkey.gpg \ http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}") end after(:each) do shell('rm /tmp/puppetlabs-pubkey.gpg') end it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '4BD6EC30', ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end context '/path/that/does/not/exist' do it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/totally_bogus.file', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/does not exist/) end end end context '/path/that/exists/with/bogus/content' do before(:each) do shell('echo "here be dragons" > /tmp/fake-key.gpg') end after(:each) do shell('rm /tmp/fake-key.gpg') end it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/fake-key.gpg', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/no valid OpenPGP data found/) end end end end describe 'options =>' do context 'debug' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', options => 'debug', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails on invalid options' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', options => 'this is totally bonkers', } EOS shell("apt-key del #{PUPPETLABS_GPG_KEY_FINGERPRINT}", :acceptable_exit_codes => [0,1,2]) apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/--keyserver-options this is totally/) end end end end describe 'fingerprint validation against source/content' do context 'fingerprint in id matches fingerprint from remote key' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) end end context 'fingerprint in id does NOT match fingerprint from remote key' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6E666', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } EOS apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/do not match/) end end end end end puppetlabs-apt-2.2.0/spec/acceptance/apt_spec.rb000644 000766 000024 00000002615 12602537170 022065 0ustar00bmjenstaff000000 000000 require 'spec_helper_acceptance' describe 'apt class' do context 'reset' do it 'fixes the sources.list' do shell('cp /etc/apt/sources.list /tmp') end end context 'all the things' do it 'should work with no errors' do pp = <<-EOS if $::lsbdistcodename == 'lucid' { $sources = undef } else { $sources = { 'puppetlabs' => { 'ensure' => present, 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu', }, }, } } class { 'apt': update => { 'frequency' => 'always', 'timeout' => '400', 'tries' => '3', }, purge => { 'sources.list' => true, 'sources.list.d' => true, 'preferences' => true, 'preferences.d' => true, }, sources => $sources, } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) end it 'should still work' do shell('apt-get update') shell('apt-get -y --force-yes upgrade') end end context 'reset' do it 'fixes the sources.list' do shell('cp /tmp/sources.list /etc/apt') end end end puppetlabs-apt-2.2.0/spec/acceptance/class_spec.rb000644 000766 000024 00000000601 12602537170 022377 0ustar00bmjenstaff000000 000000 require 'spec_helper_acceptance' describe 'apt class' do context 'default parameters' do # Using puppet_apply as a helper it 'should work with no errors' do pp = <<-EOS class { 'apt': } EOS # Run it twice and test for idempotency apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) end end end puppetlabs-apt-2.2.0/spec/acceptance/nodesets/000755 000766 000024 00000000000 12602537570 021566 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/spec/acceptance/nodesets/centos-59-x64.yml000644 000766 000024 00000000370 12602537170 024452 0ustar00bmjenstaff000000 000000 HOSTS: centos-59-x64: roles: - master platform: el-5-x86_64 box : centos-59-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git puppetlabs-apt-2.2.0/spec/acceptance/nodesets/centos-64-x64-pe.yml000644 000766 000024 00000000432 12602537170 025047 0ustar00bmjenstaff000000 000000 HOSTS: centos-64-x64: roles: - master - database - dashboard platform: el-6-x86_64 box : centos-64-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: pe puppetlabs-apt-2.2.0/spec/acceptance/nodesets/centos-65-x64.yml000644 000766 000024 00000000372 12602537170 024451 0ustar00bmjenstaff000000 000000 HOSTS: centos-65-x64: roles: - master platform: el-6-x86_64 box : centos-65-x64-vbox436-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-apt-2.2.0/spec/acceptance/nodesets/debian-70rc1-x64.yml000644 000766 000024 00000000407 12602537170 025001 0ustar00bmjenstaff000000 000000 HOSTS: debian-70rc1-x64: roles: - master platform: debian-70rc1-x64 box : debian-70rc1-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-apt-2.2.0/spec/acceptance/nodesets/debian-73-x64.yml000644 000766 000024 00000000421 12602537170 024372 0ustar00bmjenstaff000000 000000 HOSTS: debian-73-x64: roles: - master platform: debian-7-amd64 box : debian-73-x64-virtualbox-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: log_level: debug type: gitpuppetlabs-apt-2.2.0/spec/acceptance/nodesets/default.yml000644 000766 000024 00000000505 12602537170 023731 0ustar00bmjenstaff000000 000000 HOSTS: ubuntu-server-12042-x64: roles: - master platform: ubuntu-server-12.04-amd64 box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss vagrant_ssh_port_random: true puppetlabs-apt-2.2.0/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml000644 000766 000024 00000000436 12602537170 026223 0ustar00bmjenstaff000000 000000 HOSTS: ubuntu-server-10044-x64: roles: - master platform: ubuntu-10.04-amd64 box : ubuntu-server-10044-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-apt-2.2.0/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml000644 000766 000024 00000000436 12602537170 026223 0ustar00bmjenstaff000000 000000 HOSTS: ubuntu-server-12042-x64: roles: - master platform: ubuntu-12.04-amd64 box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-apt-2.2.0/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml000644 000766 000024 00000000420 12602537170 026134 0ustar00bmjenstaff000000 000000 HOSTS: ubuntu-server-1404-x64: roles: - master platform: ubuntu-14.04-amd64 box : puppetlabs/ubuntu-14.04-64-nocm box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm hypervisor : vagrant CONFIG: log_level : debug type: git puppetlabs-apt-2.2.0/manifests/backports.pp000644 000766 000024 00000002752 12602537170 021246 0ustar00bmjenstaff000000 000000 class apt::backports ( $location = undef, $release = undef, $repos = undef, $key = undef, $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') { unless $location { $_location = $::apt::backports['location'] } unless $release { $_release = "${::apt::xfacts['lsbdistcodename']}-backports" } unless $repos { $_repos = $::apt::backports['repos'] } unless $key { $_key = $::apt::backports['key'] } } else { unless $location and $release and $repos and $key { fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key') } } if is_hash($pin) { $_pin = $pin } elsif is_numeric($pin) or is_string($pin) { # apt::source defaults to pinning to origin, but we should pin to release # for backports $_pin = { 'priority' => $pin, 'release' => $_release, } } else { fail('pin must be either a string, number or hash') } apt::source { 'backports': location => $_location, release => $_release, repos => $_repos, key => $_key, pin => $_pin, } } puppetlabs-apt-2.2.0/manifests/conf.pp000644 000766 000024 00000000702 12602537170 020174 0ustar00bmjenstaff000000 000000 define apt::conf ( $content = undef, $ensure = present, $priority = '50', $notify_update = undef, ) { unless $ensure == 'absent' { unless $content { fail('Need to pass in content parameter') } } apt::setting { "conf-${name}": ensure => $ensure, priority => $priority, content => template('apt/_conf_header.erb', 'apt/conf.erb'), notify_update => $notify_update, } } puppetlabs-apt-2.2.0/manifests/init.pp000644 000766 000024 00000007305 12602537170 020220 0ustar00bmjenstaff000000 000000 # class apt( $update = {}, $purge = {}, $proxy = {}, $sources = {}, $keys = {}, $ppas = {}, $pins = {}, $settings = {}, ) inherits ::apt::params { $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') } } if $update['tries'] { unless is_integer($update['tries']) { fail('tries value for update must be an integer') } } $_update = merge($::apt::update_defaults, $update) include ::apt::update validate_hash($purge) if $purge['sources.list'] { validate_bool($purge['sources.list']) } if $purge['sources.list.d'] { validate_bool($purge['sources.list.d']) } if $purge['preferences'] { validate_bool($purge['preferences']) } if $purge['preferences.d'] { validate_bool($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']) } if $proxy['port'] { unless is_integer($proxy['port']) { fail('$proxy port must be an integer') } } if $proxy['https'] { validate_bool($proxy['https']) } $_proxy = merge($apt::proxy_defaults, $proxy) validate_hash($sources) validate_hash($keys) validate_hash($settings) validate_hash($ppas) validate_hash($pins) 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'), } } $sources_list_content = $_purge['sources.list'] ? { true => "# Repos managed by puppet.\n", default => undef, } $preferences_ensure = $_purge['preferences'] ? { true => absent, default => file, } if $_update['frequency'] == 'always' { Exec <| title=='apt_update' |> { refreshonly => false, } } apt::setting { 'conf-update-stamp': priority => 15, content => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'), } file { 'sources.list': ensure => file, path => $::apt::sources_list, owner => root, group => root, mode => '0644', content => $sources_list_content, notify => Class['apt::update'], } file { 'sources.list.d': ensure => directory, path => $::apt::sources_list_d, owner => root, group => root, mode => '0644', purge => $_purge['sources.list.d'], recurse => $_purge['sources.list.d'], notify => Class['apt::update'], } file { 'preferences': ensure => $preferences_ensure, path => $::apt::preferences, owner => root, group => root, mode => '0644', notify => Class['apt::update'], } file { 'preferences.d': ensure => directory, path => $::apt::preferences_d, owner => root, group => root, mode => '0644', purge => $_purge['preferences.d'], recurse => $_purge['preferences.d'], notify => Class['apt::update'], } # manage sources if present if $sources { create_resources('apt::source', $sources) } # manage keys if present if $keys { create_resources('apt::key', $keys) } # manage ppas if present if $ppas { create_resources('apt::ppa', $ppas) } # manage settings if present if $settings { create_resources('apt::setting', $settings) } # manage pins if present if $pins { create_resources('apt::pin', $pins) } } puppetlabs-apt-2.2.0/manifests/key.pp000644 000766 000024 00000005473 12602537170 020051 0ustar00bmjenstaff000000 000000 # == 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, ) { 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, ['\Aabsent|present\Z',]) if $_content { validate_string($_content) } if $_source { validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) } if $_server { validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) } if $_options { validate_string($_options) } 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} present"]) { apt_key { $title: ensure => $ensure, 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} absent"]){ apt_key { $title: ensure => $ensure, id => $_id, source => $_source, content => $_content, server => $_server, options => $_options, } -> anchor { "apt_key ${_id} absent": } } } default: { fail "Invalid 'ensure' value '${ensure}' for apt::key" } } } puppetlabs-apt-2.2.0/manifests/params.pp000644 000766 000024 00000010457 12602537170 020542 0ustar00bmjenstaff000000 000000 class apt::params { if $::osfamily != 'Debian' { 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 ! $::settings::strict_variables { $xfacts = { 'lsbdistcodename' => $::lsbdistcodename, 'lsbdistrelease' => $::lsbdistrelease, 'lsbmajdistrelease' => $::lsbmajdistrelease, 'lsbdistdescription' => $::lsbdistdescription, 'lsbminordistrelease' => $::lsbminordistrelease, 'lsbdistid' => $::lsbdistid, } } else { # Strict variables facts lookup compatibility $xfacts = { 'lsbdistcodename' => defined('$lsbdistcodename') ? { true => $::lsbdistcodename, default => undef, }, 'lsbdistrelease' => defined('$lsbdistrelease') ? { true => $::lsbdistrelease, default => undef, }, 'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? { true => $::lsbmajdistrelease, default => undef, }, 'lsbdistdescription' => defined('$lsbdistdescription') ? { true => $::lsbdistdescription, default => undef, }, 'lsbminordistrelease' => defined('$lsbminordistrelease') ? { true => $::lsbminordistrelease, default => undef, }, 'lsbdistid' => defined('$lsbdistid') ? { true => $::lsbdistid, default => undef, }, } } $root = '/etc/apt' $provider = '/usr/bin/apt-get' $sources_list = "${root}/sources.list" $sources_list_d = "${root}/sources.list.d" $conf_d = "${root}/apt.conf.d" $preferences = "${root}/preferences" $preferences_d = "${root}/preferences.d" $keyserver = 'keyserver.ubuntu.com' $config_files = { 'conf' => { 'path' => $conf_d, 'ext' => '', }, 'pref' => { 'path' => $preferences_d, 'ext' => '.pref', }, 'list' => { 'path' => $sources_list_d, 'ext' => '.list', } } $update_defaults = { 'frequency' => 'reluctantly', 'timeout' => undef, 'tries' => undef, } $proxy_defaults = { 'ensure' => undef, 'host' => undef, 'port' => 8080, 'https' => false, } $purge_defaults = { 'sources.list' => false, 'sources.list.d' => false, 'preferences' => false, 'preferences.d' => false, } $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef, } $include_defaults = { 'deb' => true, 'src' => false, } case $xfacts['lsbdistid'] { 'debian': { case $xfacts['lsbdistcodename'] { 'squeeze': { $backports = { 'location' => 'http://httpredir.debian.org/debian-backports', 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'repos' => 'main contrib non-free', } } default: { $backports = { 'location' => 'http://httpredir.debian.org/debian', 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'repos' => 'main contrib non-free', } } } $ppa_options = undef $ppa_package = undef } 'ubuntu': { $backports = { 'location' => 'http://archive.ubuntu.com/ubuntu', 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'repos' => 'main universe multiverse restricted', } case $xfacts['lsbdistcodename'] { 'lucid': { $ppa_options = undef $ppa_package = 'python-software-properties' } 'precise': { $ppa_options = '-y' $ppa_package = 'python-software-properties' } 'trusty', 'utopic', 'vivid': { $ppa_options = '-y' $ppa_package = 'software-properties-common' } default: { $ppa_options = '-y' $ppa_package = 'python-software-properties' } } } undef: { fail('Unable to determine lsbdistid, please install lsb-release first') } default: { $ppa_options = undef $ppa_package = undef $backports = undef } } } puppetlabs-apt-2.2.0/manifests/pin.pp000644 000766 000024 00000004640 12602537170 020042 0ustar00bmjenstaff000000 000000 # pin.pp # pin a release in apt, useful for unstable repositories define apt::pin( $ensure = present, $explanation = undef, $order = undef, $packages = '*', $priority = 0, $release = '', # a= $origin = '', $version = '', $codename = '', # n= $release_version = '', # v= $component = '', # c= $originator = '', # o= $label = '' # l= ) { if $order and !is_integer($order) { fail('Only integers are allowed in the apt::pin order param') } if $explanation { $_explanation = $explanation } else { if defined('$caller_module_name') { # strict vars check $_explanation = "${caller_module_name}: ${name}" } else { $_explanation = ": ${name}" } } $pin_release_array = [ $release, $codename, $release_version, $component, $originator, $label] $pin_release = join($pin_release_array, '') # Read the manpage 'apt_preferences(5)', especially the chapter # 'The Effect of APT Preferences' to understand the following logic # and the difference between specific and general form if is_array($packages) { $packages_string = join($packages, ' ') } else { $packages_string = $packages } if $packages_string != '*' { # specific form if ( $pin_release != '' and ( $origin != '' or $version != '' )) or ( $version != '' and ( $pin_release != '' or $origin != '' )) { fail('parameters release, origin, and version are mutually exclusive') } } else { # general form if $version != '' { fail('parameter version cannot be used in general form') } if ( $pin_release != '' and $origin != '' ) { fail('parameters release and origin are mutually exclusive') } } # According to man 5 apt_preferences: # The files have either no or "pref" as filename extension # and only contain alphanumeric, hyphen (-), underscore (_) and period # (.) characters. Otherwise APT will print a notice that it has ignored a # file, unless that file matches a pattern in the # Dir::Ignore-Files-Silently configuration list - in which case it will # be silently ignored. $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') apt::setting { "pref-${file_name}": ensure => $ensure, priority => $order, content => template('apt/_header.erb', 'apt/pin.pref.erb'), notify_update => false, } } puppetlabs-apt-2.2.0/manifests/ppa.pp000644 000766 000024 00000003731 12602537170 020034 0ustar00bmjenstaff000000 000000 # ppa.pp define apt::ppa( $ensure = 'present', $options = $::apt::ppa_options, $release = $::apt::xfacts['lsbdistcodename'], $package_name = $::apt::ppa_package, $package_manage = false, ) { unless $release { fail('lsbdistcodename fact not available: release parameter required') } if $::apt::xfacts['lsbdistid'] == 'Debian' { fail('apt::ppa is not currently supported on Debian.') } $filename_without_slashes = regsubst($name, '/', '-', 'G') $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if $ensure == 'present' { if $package_manage { package { $package_name: } $_require = [File['sources.list.d'], Package[$package_name]] } else { $_require = File['sources.list.d'] } $_proxy = $::apt::_proxy if $_proxy['host'] { if $_proxy['https'] { $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"] } else { $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"] } } else { $_proxy_env = [] } exec { "add-apt-repository-${name}": environment => $_proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", user => 'root', logoutput => 'on_failure', notify => Class['apt::update'], require => $_require, } file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => file, require => Exec["add-apt-repository-${name}"], } } else { file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => 'absent', notify => Class['apt::update'], } } } puppetlabs-apt-2.2.0/manifests/setting.pp000644 000766 000024 00000003071 12602537170 020726 0ustar00bmjenstaff000000 000000 define apt::setting ( $priority = 50, $ensure = file, $source = undef, $content = undef, $notify_update = true, ) { include 'apt::params' if $content and $source { fail('apt::setting cannot have both content and source') } if !$content and !$source { 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), '-') validate_re($setting_type, ['\Aconf\z', '\Apref\z', '\Alist\z'], "apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'") unless is_integer($priority) { # need this to allow zero-padded priority. 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'] if $notify_update { $_notify = Class['apt::update'] } else { $_notify = undef } file { "${_path}/${_priority}${base_name}${_ext}": ensure => $ensure, owner => 'root', group => 'root', mode => '0644', content => $content, source => $source, notify => $_notify, } } puppetlabs-apt-2.2.0/manifests/source.pp000644 000766 000024 00000011502 12602537170 020547 0ustar00bmjenstaff000000 000000 # 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, ) { 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 { fail('lsbdistcodename fact not available: release parameter required') } } else { $_release = $release } if $ensure == 'present' and ! $location { 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, } 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) } else { validate_string($key) $_key = merge( { 'id' => $key }, $_deprecated_key) } } apt::setting { "list-${name}": ensure => $ensure, content => template('apt/_header.erb', 'apt/source.list.erb'), } if $pin { 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] $_pin = { 'ensure' => $ensure, 'priority' => $pin, 'before' => $_before, 'origin' => $host, } } else { fail('Received invalid value for pin parameter') } create_resources('apt::pin', { "${name}" => $_pin }) } # We do not want to remove keys when the source is absent. 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, } } } } puppetlabs-apt-2.2.0/manifests/update.pp000644 000766 000024 00000003504 12602537170 020534 0ustar00bmjenstaff000000 000000 class apt::update { #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we #opt to do this, a info/warn would likely be all you'd need likely to happen #on the first run, but if it's not run in awhile something is likely borked #with apt and we'd want to know about it. case $::apt::_update['frequency'] { 'always': { $_kick_apt = true } 'daily': { #compare current date with the apt_update_last_success fact to determine #if we should kick apt_update. $daily_threshold = (strftime('%s') - 86400) if $::apt_update_last_success { if $::apt_update_last_success < $daily_threshold { $_kick_apt = true } else { $_kick_apt = false } } else { #if apt-get update has not successfully run, we should kick apt_update $_kick_apt = true } } 'weekly':{ #compare current date with the apt_update_last_success fact to determine #if we should kick apt_update. $weekly_threshold = (strftime('%s') - 604800) if $::apt_update_last_success { if ( $::apt_update_last_success < $weekly_threshold ) { $_kick_apt = true } else { $_kick_apt = false } } else { #if apt-get update has not successfully run, we should kick apt_update $_kick_apt = true } } default: { #catches 'reluctantly', and any other value (which should not occur). #do nothing. $_kick_apt = false } } if $_kick_apt { $_refresh = false } else { $_refresh = true } exec { 'apt_update': command => "${::apt::provider} update", logoutput => 'on_failure', refreshonly => $_refresh, timeout => $::apt::_update['timeout'], tries => $::apt::_update['tries'], try_sleep => 1 } } puppetlabs-apt-2.2.0/lib/facter/000755 000766 000024 00000000000 12602537570 016734 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet/000755 000766 000024 00000000000 12602537570 017005 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet_x/000755 000766 000024 00000000000 12602537570 017334 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet_x/apt_key/000755 000766 000024 00000000000 12602537570 020770 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet_x/apt_key/patch_openuri.rb000644 000766 000024 00000003500 12602537170 024147 0ustar00bmjenstaff000000 000000 require 'uri' require 'stringio' require 'time' module URI class FTP def buffer_open(buf, proxy, options) # :nodoc: if proxy OpenURI.open_http(buf, self, proxy, options) return end require 'net/ftp' directories = self.path.split(%r{/}, -1) directories.shift if directories[0] == '' # strip a field before leading slash directories.each {|d| d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") } } unless filename = directories.pop raise ArgumentError, "no filename: #{self.inspect}" end directories.each {|d| if /[\r\n]/ =~ d raise ArgumentError, "invalid directory: #{d.inspect}" end } if /[\r\n]/ =~ filename raise ArgumentError, "invalid filename: #{filename.inspect}" end typecode = self.typecode if typecode && /\A[aid]\z/ !~ typecode raise ArgumentError, "invalid typecode: #{typecode.inspect}" end # The access sequence is defined by RFC 1738 ftp = Net::FTP.open(self.host) ftp.passive = true if !options[:ftp_active_mode] # todo: extract user/passwd from .netrc. user = 'anonymous' passwd = nil user, passwd = self.userinfo.split(/:/) if self.userinfo ftp.login(user, passwd) directories.each {|cwd| ftp.voidcmd("CWD #{cwd}") } if typecode # xxx: typecode D is not handled. ftp.voidcmd("TYPE #{typecode.upcase}") end if options[:content_length_proc] options[:content_length_proc].call(ftp.size(filename)) end ftp.retrbinary("RETR #{filename}", 4096) { |str| buf << str options[:progress_proc].call(buf.size) if options[:progress_proc] } ftp.close buf.io.rewind end include OpenURI::OpenRead end end puppetlabs-apt-2.2.0/lib/puppet/provider/000755 000766 000024 00000000000 12602537570 020637 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet/type/000755 000766 000024 00000000000 12602537570 017766 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet/type/apt_key.rb000644 000766 000024 00000006237 12602537170 021753 0ustar00bmjenstaff000000 000000 require 'pathname' Puppet::Type.newtype(:apt_key) do @doc = <<-EOS This type provides Puppet with the capabilities to manage GPG keys needed by apt to perform package validation. Apt has it's own GPG keyring that can be manipulated through the `apt-key` command. apt_key { '4BD6EC30': source => 'http://apt.puppetlabs.com/pubkey.gpg' } **Autorequires**: If Puppet is given the location of a key file which looks like an absolute path this type will autorequire that file. EOS ensurable validate do if self[:content] and self[:source] fail('The properties content and source are mutually exclusive.') end if self[:id].length < 40 warning('The id should be a full fingerprint (40 characters), see README.') end end newparam(:id, :namevar => true) do desc 'The ID of the key you want to manage.' # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's # and may start with the optional 0x, or they can be 40-digit key fingerprints newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/) munge do |value| if value.start_with?('0x') id = value.partition('0x').last.upcase else id = value.upcase end id end end newparam(:content) do desc 'The content of, or string representing, a GPG key.' end newparam(:source) do desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://' newvalues(/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/) end autorequire(:file) do if self[:source] and Pathname.new(self[:source]).absolute? self[:source] end end newparam(:server) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) end newparam(:options) do desc 'Additional options to pass to apt-key\'s --keyserver-options.' end newproperty(:fingerprint) do desc <<-EOS The 40-digit hexadecimal fingerprint of the specified GPG key. This property is read-only. EOS end newproperty(:long) do desc <<-EOS The 16-digit hexadecimal id of the specified GPG key. This property is read-only. EOS end newproperty(:short) do desc <<-EOS The 8-digit hexadecimal id of the specified GPG key. This property is read-only. EOS end newproperty(:expired) do desc <<-EOS Indicates if the key has expired. This property is read-only. EOS end newproperty(:expiry) do desc <<-EOS The date the key will expire, or nil if it has no expiry date. This property is read-only. EOS end newproperty(:size) do desc <<-EOS The key size, usually a multiple of 1024. This property is read-only. EOS end newproperty(:type) do desc <<-EOS The key type, one of: rsa, dsa, ecc, ecdsa This property is read-only. EOS end newproperty(:created) do desc <<-EOS Date the key was created. This property is read-only. EOS end end puppetlabs-apt-2.2.0/lib/puppet/provider/apt_key/000755 000766 000024 00000000000 12602537570 022273 5ustar00bmjenstaff000000 000000 puppetlabs-apt-2.2.0/lib/puppet/provider/apt_key/apt_key.rb000644 000766 000024 00000014764 12602537170 024264 0ustar00bmjenstaff000000 000000 require 'open-uri' require 'net/ftp' require 'tempfile' if RUBY_VERSION == '1.8.7' # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be # monkeypatched to support passing in :ftp_passive_mode. require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'apt_key', 'patch_openuri.rb')) OpenURI::Options.merge!({:ftp_active_mode => false,}) end Puppet::Type.type(:apt_key).provide(:apt_key) do confine :osfamily => :debian defaultfor :osfamily => :debian commands :apt_key => 'apt-key' commands :gpg => '/usr/bin/gpg' def self.instances cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'] if RUBY_VERSION > '1.8.7' key_output = apt_key(cli_args).encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') else key_output = apt_key(cli_args) end pub_line, fpr_line = nil key_array = key_output.split("\n").collect do |line| if line.start_with?('pub') pub_line = line elsif line.start_with?('fpr') fpr_line = line end next unless (pub_line and fpr_line) line_hash = key_line_hash(pub_line, fpr_line) # reset everything pub_line, fpr_line = nil expired = false if line_hash[:key_expiry] expired = Time.now >= line_hash[:key_expiry] end new( :name => line_hash[:key_fingerprint], :id => line_hash[:key_long], :fingerprint => line_hash[:key_fingerprint], :short => line_hash[:key_short], :long => line_hash[:key_long], :ensure => :present, :expired => expired, :expiry => line_hash[:key_expiry].nil? ? nil : line_hash[:key_expiry].strftime("%Y-%m-%d"), :size => line_hash[:key_size], :type => line_hash[:key_type], :created => line_hash[:key_created].strftime("%Y-%m-%d") ) end key_array.compact! end def self.prefetch(resources) apt_keys = instances resources.keys.each do |name| if name.length == 40 if provider = apt_keys.find{ |key| key.fingerprint == name } resources[name].provider = provider end elsif name.length == 16 if provider = apt_keys.find{ |key| key.long == name } resources[name].provider = provider end elsif name.length == 8 if provider = apt_keys.find{ |key| key.short == name } resources[name].provider = provider end end end end def self.key_line_hash(pub_line, fpr_line) pub_split = pub_line.split(':') fpr_split = fpr_line.split(':') fingerprint = fpr_split.last return_hash = { :key_fingerprint => fingerprint, :key_long => fingerprint[-16..-1], # last 16 characters of fingerprint :key_short => fingerprint[-8..-1], # last 8 characters of fingerprint :key_size => pub_split[2], :key_type => nil, :key_created => Time.at(pub_split[5].to_i), :key_expiry => pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i), } # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz case pub_split[3] when "1" return_hash[:key_type] = :rsa when "17" return_hash[:key_type] = :dsa when "18" return_hash[:key_type] = :ecc when "19" return_hash[:key_type] = :ecdsa end return return_hash end def source_to_file(value) parsedValue = URI::parse(value) if parsedValue.scheme.nil? fail("The file #{value} does not exist") unless File.exists?(value) value else begin key = parsedValue.read rescue OpenURI::HTTPError, Net::FTPPermError => e fail("#{e.message} for #{resource[:source]}") rescue SocketError fail("could not resolve #{resource[:source]}") else tempfile(key) end end end def tempfile(content) file = Tempfile.new('apt_key') file.write content file.close #confirm that the fingerprint from the file, matches the long key that is in the manifest if name.size == 40 if File.executable? command(:gpg) extracted_key = execute(["#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false) extracted_key = extracted_key.chomp found_match = false extracted_key.each_line do |line| if line.chomp == name found_match = true end end if not found_match fail("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") end else warning('/usr/bin/gpg cannot be found for verification of the id.') end end file.path end def exists? @property_hash[:ensure] == :present end def create command = [] if resource[:source].nil? and resource[:content].nil? # Breaking up the command like this is needed because it blows up # if --recv-keys isn't the last argument. command.push('adv', '--keyserver', resource[:server]) unless resource[:options].nil? command.push('--keyserver-options', resource[:options]) end command.push('--recv-keys', resource[:id]) elsif resource[:content] command.push('add', tempfile(resource[:content])) elsif resource[:source] command.push('add', source_to_file(resource[:source])) # In case we really screwed up, better safe than sorry. else fail("an unexpected condition occurred while trying to add the key: #{resource[:id]}") end apt_key(command) @property_hash[:ensure] = :present end def destroy begin apt_key('del', resource.provider.short) r = execute(["#{command(:apt_key)} list | grep '/#{resource.provider.short}\s'"], :failonfail => false) end while r.exitstatus == 0 @property_hash.clear end def read_only(value) fail('This is a read-only property.') end mk_resource_methods # Needed until PUP-1470 is fixed and we can drop support for Puppet versions # before that. def expired @property_hash[:expired] end # Alias the setters of read-only properties # to the read_only function. alias :created= :read_only alias :expired= :read_only alias :expiry= :read_only alias :size= :read_only alias :type= :read_only end puppetlabs-apt-2.2.0/lib/facter/apt_reboot_required.rb000644 000766 000024 00000000237 12602537170 023315 0ustar00bmjenstaff000000 000000 # apt_reboot_required.rb Facter.add(:apt_reboot_required) do confine :osfamily => 'Debian' setcode do File.file?('/var/run/reboot-required') end end puppetlabs-apt-2.2.0/lib/facter/apt_update_last_success.rb000644 000766 000024 00000001125 12602537170 024155 0ustar00bmjenstaff000000 000000 require 'facter' #This is derived from the file /var/lib/apt/periodic/update-success-stamp # This is generated upon a successful apt-get update run natively in ubuntu. # the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes Facter.add('apt_update_last_success') do confine :osfamily => 'Debian' setcode do if File.exists?('/var/lib/apt/periodic/update-success-stamp') #get epoch time lastsuccess = File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i lastsuccess else lastsuccess = -1 lastsuccess end end end puppetlabs-apt-2.2.0/lib/facter/apt_updates.rb000644 000766 000024 00000002063 12602537170 021567 0ustar00bmjenstaff000000 000000 apt_package_updates = nil Facter.add("apt_has_updates") do confine :osfamily => 'Debian' if File.executable?("/usr/lib/update-notifier/apt-check") apt_check_result = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') if not apt_check_result.nil? and apt_check_result =~ /^\d+;\d+$/ apt_package_updates = apt_check_result.split(';') end end setcode do if not apt_package_updates.nil? and apt_package_updates.length == 2 apt_package_updates != ['0', '0'] end end end Facter.add("apt_package_updates") do confine :apt_has_updates => true setcode do packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1').split("\n") if Facter.version < '2.0.0' packages.join(',') else packages end end end Facter.add("apt_updates") do confine :apt_has_updates => true setcode do Integer(apt_package_updates[0]) end end Facter.add("apt_security_updates") do confine :apt_has_updates => true setcode do Integer(apt_package_updates[1]) end end puppetlabs-apt-2.2.0/examples/backports.pp000644 000766 000024 00000000515 12602537170 021066 0ustar00bmjenstaff000000 000000 # Set up a backport for linuxmint qiana class { 'apt': } apt::backports { 'qiana': location => 'http://us.archive.ubuntu.com/ubuntu', release => 'trusty-backports', repos => 'main universe multiverse restricted', key => { id => '630239CC130E1A7FD81A27B140976EAF437D05B5', server => 'pgp.mit.edu', }, } puppetlabs-apt-2.2.0/examples/builddep.pp000644 000766 000024 00000000101 12602537170 020655 0ustar00bmjenstaff000000 000000 package{ 'glusterfs-server': install_options => 'build-dep', } puppetlabs-apt-2.2.0/examples/debian_testing.pp000644 000766 000024 00000000613 12602537170 022054 0ustar00bmjenstaff000000 000000 package { 'debian-keyring': ensure => present } package { 'debian-archive-keyring': ensure => present } apt::source { 'debian_testing': location => 'http://debian.mirror.iweb.ca/debian/', release => 'testing', repos => 'main contrib non-free', pin => '-10', key => { id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', server => 'subkeys.pgp.net', }, } puppetlabs-apt-2.2.0/examples/debian_unstable.pp000644 000766 000024 00000000615 12602537170 022216 0ustar00bmjenstaff000000 000000 package { 'debian-keyring': ensure => present } package { 'debian-archive-keyring': ensure => present } apt::source { 'debian_unstable': location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', pin => '-10', key => { id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', server => 'subkeys.pgp.net', }, } puppetlabs-apt-2.2.0/examples/disable_keys.pp000644 000766 000024 00000000271 12602537170 021533 0ustar00bmjenstaff000000 000000 #Note: This is generally a bad idea. You should not disable verifying repository signatures. apt::conf { 'unauth': priority => 99, content => 'APT::Get::AllowUnauthenticated 1;' } puppetlabs-apt-2.2.0/examples/fancy_progress.pp000644 000766 000024 00000000132 12602537170 022115 0ustar00bmjenstaff000000 000000 apt::conf { 'progressbar': priority => 99, content => 'Dpkg::Progress-Fancy "1";', } puppetlabs-apt-2.2.0/examples/force.pp000644 000766 000024 00000001331 12602537170 020171 0ustar00bmjenstaff000000 000000 #if you need to specify a release $rel_string = '-t ' #else $rel_string = '' #if you need to specify a version $ensure = '' #else $ensure = installed #if overwrite existing cfg files $config_files = '-o Dpkg::Options::="--force-confnew"' #elsif force use of old files $config_files = '-o Dpkg::Options::="--force-confold"' #elsif update only unchanged files $config_files = '-o Dpkg::Options::="--force-confdef"' #else $config_files = '' #if install missing configuration files for the package $config_missing = '-o Dpkg::Options::="--force-confmiss"' #else $config_missing = '' package { '': ensure => $ensure, install_options => "${config_files} ${config_missing} ${rel_string}", } puppetlabs-apt-2.2.0/examples/hold.pp000644 000766 000024 00000000137 12602537170 020024 0ustar00bmjenstaff000000 000000 apt::pin { 'hold-vim': packages => 'vim', version => '2:7.4.488-5', priority => 1001, } puppetlabs-apt-2.2.0/examples/key.pp000644 000766 000024 00000000351 12602537170 017664 0ustar00bmjenstaff000000 000000 # Declare Apt key for apt.puppetlabs.com source apt::key { 'puppetlabs': id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', server => 'pgp.mit.edu', options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', } puppetlabs-apt-2.2.0/examples/pin.pp000644 000766 000024 00000000161 12602537170 017661 0ustar00bmjenstaff000000 000000 # pin a release in apt, useful for unstable repositories apt::pin { 'foo': packages => '*', priority => 0, } puppetlabs-apt-2.2.0/examples/ppa.pp000644 000766 000024 00000000145 12602537170 017655 0ustar00bmjenstaff000000 000000 class { 'apt': } # Example declaration of an Apt PPA apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } puppetlabs-apt-2.2.0/examples/release.pp000644 000766 000024 00000000135 12602537170 020514 0ustar00bmjenstaff000000 000000 apt::conf { 'release': content => 'APT::Default-Release "karmic";', priority => '01', } puppetlabs-apt-2.2.0/examples/source.pp000644 000766 000024 00000001777 12602537170 020411 0ustar00bmjenstaff000000 000000 # Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d class { 'apt': } # Install the puppetlabs apt source # Release is automatically obtained from lsbdistcodename fact if available. apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', key => { id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', server => 'pgp.mit.edu', }, } # test two sources with the same key apt::source { 'debian_testing': location => 'http://debian.mirror.iweb.ca/debian/', release => 'testing', repos => 'main contrib non-free', key => { id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', server => 'subkeys.pgp.net', }, pin => '-10', } apt::source { 'debian_unstable': location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', key => { id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', server => 'subkeys.pgp.net', }, pin => '-10', } puppetlabs-apt-2.2.0/examples/unattended_upgrades.pp000644 000766 000024 00000000007 12602537170 023117 0ustar00bmjenstaff000000 000000 # TODO