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