]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge remote-tracking branch 'upstream/master' into merge_master_to_next
authorMorgan Haskel <morgan@puppetlabs.com>
Wed, 25 Mar 2015 22:32:09 +0000 (18:32 -0400)
committerMorgan Haskel <morgan@puppetlabs.com>
Wed, 25 Mar 2015 22:32:09 +0000 (18:32 -0400)
76 files changed:
.fixtures.yml
.travis.yml
README.md
examples/backports.pp [new file with mode: 0644]
examples/builddep.pp [new file with mode: 0644]
examples/force.pp [new file with mode: 0644]
examples/hold.pp [new file with mode: 0644]
examples/key.pp [moved from tests/key.pp with 100% similarity]
examples/pin.pp [moved from tests/pin.pp with 100% similarity]
examples/ppa.pp [moved from tests/ppa.pp with 100% similarity]
examples/proxy.pp [new file with mode: 0644]
examples/release.pp [new file with mode: 0644]
examples/source.pp [moved from tests/source.pp with 100% similarity]
examples/unattended_upgrades.pp [new file with mode: 0644]
lib/puppet/provider/apt_key/apt_key.rb
lib/puppet/type/apt_key.rb
manifests/backports.pp [deleted file]
manifests/builddep.pp [deleted file]
manifests/conf.pp
manifests/debian/testing.pp [deleted file]
manifests/debian/unstable.pp [deleted file]
manifests/force.pp [deleted file]
manifests/hold.pp [deleted file]
manifests/init.pp
manifests/key.pp
manifests/params.pp
manifests/pin.pp
manifests/ppa.pp
manifests/release.pp [deleted file]
manifests/setting.pp [new file with mode: 0644]
manifests/source.pp
manifests/unattended_upgrades.pp [deleted file]
manifests/update.pp
metadata.json
spec/acceptance/apt_key_provider_spec.rb
spec/acceptance/apt_spec.rb
spec/classes/apt_spec.rb
spec/classes/apt_update_spec.rb
spec/classes/backports_spec.rb [deleted file]
spec/classes/debian_testing_spec.rb [deleted file]
spec/classes/debian_unstable_spec.rb [deleted file]
spec/classes/params_spec.rb
spec/classes/release_spec.rb [deleted file]
spec/classes/unattended_upgrades_spec.rb [deleted file]
spec/defines/builddep_spec.rb [deleted file]
spec/defines/conf_spec.rb
spec/defines/force_spec.rb [deleted file]
spec/defines/hold_spec.rb [deleted file]
spec/defines/key_spec.rb
spec/defines/pin_spec.rb
spec/defines/ppa_spec.rb
spec/defines/setting_spec.rb [new file with mode: 0644]
spec/defines/source_spec.rb
spec/spec_helper_acceptance.rb
spec/unit/facter/apt_has_updates_spec.rb
spec/unit/facter/apt_package_updates_spec.rb
spec/unit/facter/apt_security_updates_spec.rb
spec/unit/facter/apt_update_last_success_spec.rb
spec/unit/facter/apt_updates_spec.rb
spec/unit/puppet/type/apt_key_spec.rb
templates/10periodic.erb [deleted file]
templates/50unattended-upgrades.erb [deleted file]
templates/pin.pref.erb
templates/progressbar.erb [deleted file]
templates/proxy.erb
templates/release.erb [deleted file]
templates/source.list.erb
templates/unauth.erb [deleted file]
tests/builddep.pp [deleted file]
tests/debian/testing.pp [deleted file]
tests/debian/unstable.pp [deleted file]
tests/force.pp [deleted file]
tests/init.pp [deleted file]
tests/params.pp [deleted file]
tests/release.pp [deleted file]
tests/unattended_upgrades.pp [deleted file]

index 2bb941de23740d660a9769b18bb67a2e8e7d4bdc..578437cb9f0074e35ffb8b504f5f6c600d8c4b23 100644 (file)
@@ -2,6 +2,6 @@ fixtures:
   repositories:
     "stdlib":
       "repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
-      "ref": "v2.2.1"
+      "ref": "4.5.0"
   symlinks:
     "apt": "#{source_dir}"
index ec6f08dc6dca8b71161ba56ee240e358154975d8..8b374e9bb0c3322e6157a975c50f17aabaf95a5b 100644 (file)
@@ -1,5 +1,6 @@
 ---
 language: ruby
+sudo: false
 bundler_args: --without system_tests
 script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
 matrix:
index 3fd74b3d2c5ae48f764e9edcb3d547e96e87e883..26feda3818cc2f758bf9d5289dc764b72c798e71 100644 (file)
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ The apt module automates obtaining and installing software packages on \*nix sys
 * System repositories
 * Authentication keys
 
-**Note**: Setting the apt module's `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will **destroy** any existing content that was not declared with Puppet. The default for these parameters is 'false'.
+**Note**: By default, this module will **destroy** any existing content in `sources.list` and `sources.list.d` that was not declared with Puppet.
 
 ### Beginning with apt
 
@@ -31,58 +31,19 @@ Any Puppet code that uses anything from the apt module requires that the core ap
 
 Using the apt module consists predominantly of declaring classes and defined types that provide the desired functionality and features. This module provides common resources and options that are shared by the various defined types in the apt module, so you **must always** include this class in your manifests.
 
-```
-class { 'apt':
-  always_apt_update    => false,
-  apt_update_frequency => undef,
-  disable_keys         => undef,
-  proxy_host           => false,
-  proxy_port           => '8080',
-  purge_sources_list   => false,
-  purge_sources_list_d => false,
-  purge_preferences_d  => false,
-  update_timeout       => undef,
-  fancy_progress       => undef
-}
+```puppet
+class { 'apt': }
 ```
 
 ## Reference
 
 ### Classes
 
-* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory, but it does its best to respect existing content.
-
-  If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
+* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will purge any existing content it finds that wasn't declared with Puppet.
   
-* `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined and potentially serious behavior.
-
-  By default, this class drops a pin-file for backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from backports without your explicit permission.
-
-  If you raise the priority through the `pin_priority` parameter to 500---identical to the rest of the Debian mirrors---normal policy goes into effect, and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version.
-
 * `apt::params`: Sets defaults for the apt module parameters.
 
-* `apt::release`: Sets the default Apt release. This class is particularly useful when using repositories that are unstable in Ubuntu, such as Debian.
-
-  ```
-  class { 'apt::release':
-    release_id => 'precise',
-  }
-  ```  
-
-* `apt::unattended_upgrades`: This class manages the unattended-upgrades package and related configuration files for Ubuntu and Debian systems. You can configure the class to automatically upgrade all new package releases or just security releases.
-
-  ```
-  class { 'apt::unattended_upgrades':
-    blacklist     => [],
-    update        => '1',
-    download      => '1',
-    upgrade       => '1',
-    autoclean     => '7',
-  }
-  ```
-  
-* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify  => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter to 'true', the update runs on every Puppet run.
+* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify  => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `'always'`, the update runs on every Puppet run.
 
 ### Types
 
@@ -90,7 +51,7 @@ class { 'apt':
 
   A native Puppet type and provider for managing GPG keys for Apt is provided by this module.
 
-  ```
+  ```puppet
   apt_key { 'puppetlabs':
     ensure => 'present',
     id     => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
@@ -102,74 +63,29 @@ class { 'apt':
    * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the target host.
    * `content`: Instead of pointing to a file, pass the key in as a string.
    * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*.
-   * `keyserver_options`: Additional options to pass to `--keyserver`.
-
-  Because apt_key is a native type, you can use it and query for it with MCollective. 
+   * `options`: Additional options to pass to `apt-key`'s `--keyserver-options`.
 
 ### Defined Types
 
-* `apt::builddep`: Installs the build dependencies of a specified package.
-
-  `apt::builddep { 'glusterfs-server': }`
-    
 * `apt::conf`: Specifies a custom configuration file. The priority defaults to 50, but you can set the priority parameter to load the file earlier or later. The content parameter passes specified content, if any, into the file resource.
 
-* `apt::hold`: Holds a specific version of a package. You can hold a package to a full version or a partial version.
-
-  To set a package's ensure attribute to 'latest' but get the version specified by `apt::hold`:
-
-  ```
-  apt::hold { 'vim':
-    version => '2:7.3.547-7',
-  }
-  ```
-
-  Alternatively, if you want to hold your package at a partial version, you can use a wildcard. For example, you can hold Vim at version 7.3.*:
-
-
-  ```
-  apt::hold { 'vim':
-    version => '2:7.3.*',
-  }
-  ```
-
-* `apt::force`: Forces a package to be installed from a specific release. This is particularly useful when using repositories that are unstable in Ubuntu, such as Debian.
-
-  ```
-  apt::force { 'glusterfs-server':
-    release     => 'unstable',
-    version     => '3.0.3',
-    cfg_files   => 'unchanged',
-    cfg_missing => true,
-    require => Apt::Source['debian_unstable'],
-  }
-  ```
+* `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt\_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended.
 
-  Valid values for `cfg_files` are:
-    * 'new': Overwrites all existing configuration files with newer ones.
-    * 'old': Forces usage of all old files.
-    * 'unchanged: Updates only unchanged config files.
-    * 'none': Provides backward-compatibility with existing Puppet manifests.
-   
-  Valid values for `cfg_missing` are 'true', 'false'. Setting this to 'false' provides backward compatibility; setting it to 'true' checks for and installs missing configuration files for the selected package.
-
-* `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended.
-
-  ```
+  ```puppet
   apt::key { 'puppetlabs':
-    key        => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
-    key_server => 'pgp.mit.edu',
+    id     => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
+    server => 'pgp.mit.edu',
   }
 
   apt::key { 'jenkins':
-    key        => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6',
-    key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
+    id     => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6',
+    source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
   }
   ```
 
 * `apt::pin`: Defined type that adds an Apt pin for a certain release.
 
-  ```
+  ```puppet
   apt::pin { 'karmic': priority => 700 }
   apt::pin { 'karmic-updates': priority => 700 }
   apt::pin { 'karmic-security': priority => 700 }
@@ -177,7 +93,7 @@ class { 'apt':
 
   Note that you can also specify more complex pins using distribution properties.
 
-  ```
+  ```puppet
   apt::pin { 'stable':
     priority        => -10,
     originator      => 'Debian',
@@ -191,147 +107,128 @@ class { 'apt':
 
 * `apt::ppa`: Adds a PPA repository using `add-apt-repository`. For example, `apt::ppa { 'ppa:drizzle-developers/ppa': }`.
 
+* `apt::setting`: Defined type to abstract the creation of Apt configuration files.
+
 * `apt::source`: Adds an Apt source to `/etc/apt/sources.list.d/`. For example:
 
-  ```
+  ```puppet
   apt::source { 'debian_unstable':
-    comment           => 'This is the iWeb Debian unstable mirror',
-    location          => 'http://debian.mirror.iweb.ca/debian/',
-    release           => 'unstable',
-    repos             => 'main contrib non-free',
-    required_packages => 'debian-keyring debian-archive-keyring',
-    key               => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-    key_server        => 'subkeys.pgp.net',
-    pin               => '-10',
-    include_src       => true,
-    include_deb       => true
+    comment  => 'This is the iWeb Debian unstable mirror',
+    location => 'http://debian.mirror.iweb.ca/debian/',
+    release  => 'unstable',
+    repos    => 'main contrib non-free',
+    pin      => '-10',
+    key      => {
+      'id'     => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
+      'server' => 'subkeys.pgp.net',
+    },
+    include  => {
+      'src' => true,
+      'deb' => true,
+    },
   }
   ```  
 
   For example, to configure your system so the source is the Puppet Labs Apt repository:
 
-  ```
+  ```puppet
   apt::source { 'puppetlabs':
-    location   => 'http://apt.puppetlabs.com',
-    repos      => 'main dependencies',
-    key        => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
-    key_server => 'pgp.mit.edu',
-  }
+    location => 'http://apt.puppetlabs.com',
+    repos    => 'main',
+    key      => {
+      'id'     => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
+      'server' => 'pgp.mit.edu',
+    },
   ```
 
 ### Facts
 
 The apt module includes a few facts to describe the state of the Apt system:
 
-* `apt_updates`: The number of updates available on the system
-* `apt_security_updates`: The number of updates which are security updates
-* `apt_package_updates`: The package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string.
-* `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run. This is determined by reading the mtime of  /var/lib/apt/periodic/update-success-stamp.
+* `apt\_updates`: The number of updates available on the system
+* `apt\_security\_updates`: The number of updates which are security updates
+* `apt\_package\_updates`: The package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string.
+* `apt\_update\_last\_success`: The date, in epochtime, of the most recent successful `apt-get update` run. This is determined by reading the mtime of  /var/lib/apt/periodic/update-success-stamp.
 
 **Note:** The facts depend on 'update-notifier' being installed on your system. Though this is a GNOME daemon only the support files are needed so the package 'update-notifier-common' is enough to enable this functionality.
 
 #### Hiera example
 
-```
-<pre>
+```yaml
 apt::sources:
   'debian_unstable':
     location: 'http://debian.mirror.iweb.ca/debian/'
     release: 'unstable'
     repos: 'main contrib non-free'
-    required_packages: 'debian-keyring debian-archive-keyring'
-    key: '9AA38DCD55BE302B'
-    key_server: 'subkeys.pgp.net'
+    key:
+      id: '9AA38DCD55BE302B'
+      server: 'subkeys.pgp.net'
     pin: '-10'
-    include_src: true
-    include_deb: true
+    include:
+      src: true
+      deb: true
 
   'puppetlabs':
     location: 'http://apt.puppetlabs.com'
-    repos: 'main dependencies'
-    key: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
-    key_server: 'pgp.mit.edu'
-</pre>
+    repos: 'main'
+    key:
+      id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
+      server: 'pgp.mit.edu'
 ```
 
 ### Parameters
 
 #### apt
 
-* `always_apt_update`: Set to 'true' to update Apt on every run. This setting is intended for development environments where package updates are frequent. Defaults to 'false'. 
-* `apt_update_frequency`: Sets the run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values:
-  * 'always': Runs update at every Puppet run.
-  * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 86400. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. 
-  * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 604800. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. 
-  * 'reluctantly': Only runs `apt-get update` if the exec resource `apt_update` is notified. This is the default setting.  
-* `disable_keys`: Disables the requirement for all packages to be signed.
-* `proxy_host`: Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy.
-* `proxy_port`: Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy.
-* `purge_sources_list`: If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts 'true' or 'false'. Defaults to 'false'.
-* `purge_sources_list_d`: If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts 'true' or 'false'. Defaults to 'false'.
-* `update_timeout`: Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300).
-* `update_tries`: Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once.
-* `sources`: Passes a hash to create_resource to make new `apt::source` resources.
-* `fancy_progress`: Enables fancy progress bars for apt. Accepts 'true', 'false'. Defaults to 'false'.
-
-####apt::unattended_upgrades
-
-* `legacy_origin`: If set to true, use the old `Unattended-Upgrade::Allowed-Origins` variable. If false, use `Unattended-Upgrade::Origins-Pattern`. OS-dependent defaults are defined in `apt::params`.
-* `origins`: The repositories from which to automatically upgrade included packages. OS-dependent defaults are defined in `apt::params`. (Usually only security updates are enabled by default)
-* `blacklist`: A list of packages to **not** automatically upgrade. This list is empty by default.
-* `update`: How often, in days, to run `apt-get update`. Defaults to '1'.
-* `download`: How often, in days, to run `apt-get upgrade --download-only`. Defaults to '1'.
-* `upgrade`: How often, in days, to upgrade packages included in the origins list. Defaults to '1'.
-* `autoclean`: How often, in days, to run `apt-get autoclean`. Defaults to '7'.
-* `auto_fix`: Tries to automatically fix interrupted package installations. Defaults to 'true'.
-* `minimal_steps`: Split the upgrade process into sections to allow shutdown during upgrade. Defaults to 'false'.
-* `install_on_shutdown`: Install updates on shutdown instead of in the background. Defaults to 'false'.
-* `mail_to`: Send e-mail to this address about packages upgrades or errors. This is not set by default.
-* `mail_only_on_error`: Send e-mail only in case of error, not on successful upgrade. Defaults to 'false'.
-* `remove_unused`: Removes unused dependencies. Defaults to 'true'.
-* `auto_reboot`: Reboot the system **without confirmation** if an update requires rebooting. Defaults to 'false'.
-* `dl_limit`: Use a bandwidth limit for downloading, specified in kb/sec. This is not set by default.
-* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. This is not set by default.
-
-####apt::source
-
-* `comment`: Add a comment to the apt source file.
-* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'.
-* `location`: The URL of the apt repository.
-* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'.
-* `repos`: The component of the apt repository. This defaults to 'main'.
-* `include_deb`: References a Debian distribution's binary package.
-* `include_src`: Enable the deb-src type, references a Debian distribution's source code in the same form as the include_deb type. A deb-src line is required to fetch source indexes.
-* `required_packages`: install required packages via an exec. defaults to 'false'.
-* `key`: See apt::key
-* `key_server`: See apt::key
-* `key_content`: See apt::key
-* `key_source`: See apt::key
-* `pin`: See apt::pin
-* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc'.
-* `trusted_source` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'.
+* `update`: Hash to configure various update settings. Valid keys are:
+  * 'frequency': The run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values:
+    * 'always': Runs update at every Puppet run.
+    * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt\_update\_last\_success` is less than current epoch time - 86400. If the exec resource `apt\_update` is notified, `apt-get update` runs regardless of this value. 
+    * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt\_update\_last\_success` is less than current epoch time - 604800. If the exec resource `apt\_update` is notified, `apt-get update` runs regardless of this value. 
+    * 'reluctantly': Only runs `apt-get update` if the exec resource `apt\_update` is notified. This is the default setting.  
+  * 'timeout': Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300).
+  * 'tries': Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once.
+* `purge`: Hash to configure various purge settings. Valid keys are:
+  * 'sources.list': If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts `true` or `false`. Defaults to `true`.
+  * 'sources.list.d': If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts `true` or `false`. Defaults to `true`.
+  * 'preferences.list': If set to 'true', Puppet purges all unmanaged entries from preferences.list. Accepts `true` or `false`. Defaults to `true`.
+  * 'preferences.list.d': If set to 'true', Puppet purges all unmanaged entries from preferences.list.d. Accepts `true` or `false`. Defaults to `true`.
+* `proxy`: Hash to configure various proxy settings. Valid keys are:
+  * 'host': Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy.
+  * 'port': Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy.
+  * 'https': Boolean to configure whether or not to enable https proxies. Defaults to false.
+* `keys`: Passes a hash to `create\_resource` to make new `apt::key` resources.
+* `ppas`: Passes a hash to `create\_resource` to make new `apt::ppa` resources.
+* `settings`: Passes a hash to `create\_resource` to make new `apt::setting` resources.
+* `sources`: Passes a hash to `create\_resource` to make new `apt::source` resources.
+
+####apt::conf
+
+* `content`: The content of the configuration file.
+* `ensure`: Whether the configuration file should be 'present' or 'absent'. Defaults to 'present'.
+* `priority`: Numeric priority for the configuration file. Defaults to '50'.
 
 ####apt::key
 
 * `ensure`: The state we want this key in. Can be 'present' or 'absent'.
-* `key`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints.
-* `key_content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient.
-* `key_source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system).
-* `key_server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to undef which results in apt_key's default keyserver being used, currently `keyserver.ubuntu.com`.
-* `key_options`: Additional options to pass on to `apt-key adv --keyserver-options`.
+* `id`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints.
+* `content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient.
+* `source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system).
+* `server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to 'keyserver.ubuntu.com'.
+* `options`: Additional options to pass on to `apt-key adv --keyserver-options`.
 
 ####apt::pin
 
 * `ensure`: The state we want this pin in. Can be 'present' or 'absent'.
-* `explanation`: Add a comment. Defaults to `${caller_module_name}: ${name}`.
-* `order`: The order of the file name. Defaults to '', otherwise must be an integer.
+* `explanation`: Add a comment. Defaults to `${caller\_module\_name}: ${name}`.
+* `order`: The order of the file name. Defaults to undef, otherwise must be an integer.
 * `packages`: The list of packages to pin. Defaults to '\*'. Can be an array or string. 
 * `priority`: Several versions of a package may be available for installation when the sources.list(5) file contains references to more than one distribution (for example, stable and testing). APT assigns a priority to each version that is available. Subject to dependency constraints, apt-get selects the version with the highest priority for installation.
 * `release`: The Debian release. Defaults to ''. Typical values can be 'stable', 'testing' and 'unstable'.
 * `origin`: Can be used to match a hostname. The following record will assign a high priority to all versions available from the server identified by the hostname. Defaults to ''.
 * `version`: The specific form assigns a priority (a "Pin-Priority") to one or more specified packages with a specified version or version range.
 * `codename`: The distribution (lsbdistcodename) of the apt repository. Defaults to ''.
-* `release_version`: Names the release version. For example, the packages in the tree might belong to Debian release version 7. Defaults to ''.
+* `release\_version`: Names the release version. For example, the packages in the tree might belong to Debian release version 7. Defaults to ''.
 * `component`: Names the licensing component associated with the packages in the directory tree of the Release file. defaults to ''. Typical values can be 'main', 'dependencies' and 'restricted'
 * `originator`: Names the originator of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian.
 * `label`: Names the label of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian.
@@ -345,44 +242,36 @@ It is recommended to read the manpage 'apt_preferences(5)'
 * `ensure`: Whether we are adding or removing the PPA. Can be 'present' or 'absent'. Defaults to 'present'.
 * `release`: The codename for the operating system you're running. Defaults to `$lsbdistcodename`. Required if lsb-release is not installed.
 * `options`: Options to be passed to the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`.
-* `package_name`: The package that provides the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`.
-* `package_manage`: Whether or not to manage the package providing `apt-add-repository`. Defaults to true.
-
-### Testing
-
-The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources.
-
-#### Example Test
-
-This test sets up a Puppet Labs Apt repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs Apt source and GPG key:
-
-```
-class { 'apt': }
-
-apt::source { 'puppetlabs':
-  location   => 'http://apt.puppetlabs.com',
-  repos      => 'main dependencies',
-  key        => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
-  key_server => 'pgp.mit.edu',
-}
-```    
+* `package\_name`: The package that provides the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`.
+* `package\_manage`: Whether or not to manage the package providing `apt-add-repository`. Defaults to true.
 
-This resource creates an Apt source named puppetlabs and gives Puppet information about the repository's location and the key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set this directly by adding the release type.
+####apt::setting
 
-Check your smoke test for syntax errors:
+* `priority`: Integer or zero-padded integer setting the file priority. Defaults to 50.
+* `ensure`: Whether to add or remove the file. Valid values are 'present', 'absent', and 'file'. Defaults to `file`.
+* `source`: The source for the file. Exactly one of `content` and `source` must be specified.
+* `content`: The content for the file. Exactly one of `content` and `source` must be specified.
+* `notify\_update`: Boolean for whether or not this `apt::setting` should trigger an `apt-get update`. Defaults to `true`.
 
-`$ puppet parser validate tests/puppetlabs-apt.pp`
-
-If you receive no output from that command, it means nothing is wrong. Then, apply the code:
-
-```
-$ puppet apply --verbose tests/puppetlabs-apt.pp
-notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e'
-info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update]
-notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events>
-```    
+####apt::source
 
-The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your Apt sources inside the classes where they're needed.
+* `comment`: Add a comment to the apt source file.
+* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'.
+* `location`: The URL of the apt repository. Defaults to undef. Required unless `ensure => 'absent'`.
+* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'.
+* `repos`: The component of the apt repository. This defaults to 'main'.
+* `include`: Hash to configure include options. Valid keys are:
+  * 'deb': References a Debian distribution's binary package. Defaults to `true`.
+  * 'src': Enable the deb-src type, references a Debian distribution's source code in the same form as the `include['deb']` type. A deb-src line is required to fetch source indexes. Defaults to `false`.
+* `key`: Add key from source. Takes either a string or a hash. If a string, the value will be passed to `id` in the `apt::key`. If a hash, valid keys are:
+  * 'id': See `id` in `apt::key`. Required if a hash is specified.
+  * 'server': See `server` in `apt::key`
+  * 'content': See `content` in `apt::key`
+  * 'source': See `source` in `apt::key`
+  * 'options': See `options` in `apt::key`
+* `pin`: See apt::pin. Defaults to false.
+* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to `undef` which means all. Example values can be 'i386' or 'i386,alpha,powerpc'.
+* `allow\_unsigned`: can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to `false`. Can be `true` or `false`.
 
 Limitations
 -----------
diff --git a/examples/backports.pp b/examples/backports.pp
new file mode 100644 (file)
index 0000000..4640904
--- /dev/null
@@ -0,0 +1 @@
+# TODO
diff --git a/examples/builddep.pp b/examples/builddep.pp
new file mode 100644 (file)
index 0000000..deaaef8
--- /dev/null
@@ -0,0 +1,3 @@
+package{ 'glusterfs-server':
+  install_options => 'build-dep',
+}
diff --git a/examples/force.pp b/examples/force.pp
new file mode 100644 (file)
index 0000000..36d23f8
--- /dev/null
@@ -0,0 +1,2 @@
+# force.pp
+# TODO: Update
diff --git a/examples/hold.pp b/examples/hold.pp
new file mode 100644 (file)
index 0000000..00f760c
--- /dev/null
@@ -0,0 +1,5 @@
+apt::pin { 'hold-vim':
+  packages => 'vim',
+  version  => '2:7.4.488-5',
+  priority => 1001,
+}
similarity index 100%
rename from tests/key.pp
rename to examples/key.pp
similarity index 100%
rename from tests/pin.pp
rename to examples/pin.pp
similarity index 100%
rename from tests/ppa.pp
rename to examples/ppa.pp
diff --git a/examples/proxy.pp b/examples/proxy.pp
new file mode 100644 (file)
index 0000000..4640904
--- /dev/null
@@ -0,0 +1 @@
+# TODO
diff --git a/examples/release.pp b/examples/release.pp
new file mode 100644 (file)
index 0000000..46d6893
--- /dev/null
@@ -0,0 +1,4 @@
+apt::conf { 'release':
+  content  => 'APT::Default-Release "karmic";',
+  priority => '01',
+}
similarity index 100%
rename from tests/source.pp
rename to examples/source.pp
diff --git a/examples/unattended_upgrades.pp b/examples/unattended_upgrades.pp
new file mode 100644 (file)
index 0000000..4640904
--- /dev/null
@@ -0,0 +1 @@
+# TODO
index cd68d37063117142b409c9f17dbe1d606b4e9ded..bac5b373e937a2a366912e18eceb249e271485e4 100644 (file)
@@ -161,8 +161,8 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       # Breaking up the command like this is needed because it blows up
       # if --recv-keys isn't the last argument.
       command.push('adv', '--keyserver', resource[:server])
-      unless resource[:keyserver_options].nil?
-        command.push('--keyserver-options', resource[:keyserver_options])
+      unless resource[:options].nil?
+        command.push('--keyserver-options', resource[:options])
       end
       command.push('--recv-keys', resource[:id])
     elsif resource[:content]
index 7130496ea9e55dafaf4e3386a59c7645ffa601dd..81b66a263862fa5bed5895c633865173469d09b5 100644 (file)
@@ -61,11 +61,11 @@ Puppet::Type.newtype(:apt_key) do
   newparam(:server) do
     desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.'
     defaultto :'keyserver.ubuntu.com'
-    
+
     newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/)
   end
 
-  newparam(:keyserver_options) do
+  newparam(:options) do
     desc 'Additional options to pass to apt-key\'s --keyserver-options.'
   end
 
diff --git a/manifests/backports.pp b/manifests/backports.pp
deleted file mode 100644 (file)
index ff8cb44..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-# This adds the necessary components to get backports for ubuntu and debian
-#
-# == Parameters
-#
-# [*release*]
-#   The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this
-#   manually can cause undefined behavior. (Read: universe exploding)
-#
-# [*pin_priority*]
-#   _default_: 200
-#
-#   The priority that should be awarded by default to all packages coming from
-#   the Debian Backports project.
-#
-# == Examples
-#
-#   include apt::backports
-#
-#   class { 'apt::backports':
-#     release => 'natty',
-#   }
-#
-# == Authors
-#
-# Ben Hughes, I think. At least blame him if this goes wrong.
-# I just added puppet doc.
-#
-# == Copyright
-#
-# Copyright 2011 Puppet Labs Inc, unless otherwise noted.
-class apt::backports(
-  $release      = $::lsbdistcodename,
-  $location     = $::apt::params::backports_location,
-  $pin_priority = 200,
-) inherits apt::params {
-
-  if ! is_integer($pin_priority) {
-    fail('$pin_priority must be an integer')
-  }
-
-  if $::lsbdistid == 'LinuxMint' {
-    if $::lsbdistcodename == 'debian' {
-      $distid = 'debian'
-      $release_real = 'wheezy'
-    } else {
-      $distid = 'ubuntu'
-      $release_real = $::lsbdistcodename ? {
-        'qiana'  => 'trusty',
-        'petra'  => 'saucy',
-        'olivia' => 'raring',
-        'nadia'  => 'quantal',
-        'maya'   => 'precise',
-      }
-    }
-  } else {
-    $distid = $::lsbdistid
-    $release_real = downcase($release)
-  }
-
-  $key = $distid ? {
-    'debian' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-    'ubuntu' => '630239CC130E1A7FD81A27B140976EAF437D05B5',
-  }
-  $repos = $distid ? {
-    'debian' => 'main contrib non-free',
-    'ubuntu' => 'main universe multiverse restricted',
-  }
-
-  apt::pin { 'backports':
-    before   => Apt::Source['backports'],
-    release  => "${release_real}-backports",
-    priority => $pin_priority,
-  }
-
-  apt::source { 'backports':
-    location   => $location,
-    release    => "${release_real}-backports",
-    repos      => $repos,
-    key        => $key,
-    key_server => 'pgp.mit.edu',
-  }
-}
diff --git a/manifests/builddep.pp b/manifests/builddep.pp
deleted file mode 100644 (file)
index 3a059c2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# builddep.pp
-
-define apt::builddep() {
-  include apt::update
-
-  exec { "apt-builddep-${name}":
-    command   => "/usr/bin/apt-get -y --force-yes build-dep ${name}",
-    logoutput => 'on_failure',
-    require   => Exec['apt_update'],
-  }
-
-  # Need anchor to provide containment for dependencies.
-  anchor { "apt::builddep::${name}":
-    require => Class['apt::update'],
-  }
-}
index 318422e29323933eb2b8f3d315037e421d4d1a4c..28502052814b73a238d7fc6704a05ae70811cd47 100644 (file)
@@ -1,18 +1,11 @@
 define apt::conf (
   $content,
   $ensure   = present,
-  $priority = '50'
+  $priority = '50',
 ) {
-
-  include apt::params
-
-  $apt_conf_d = $apt::params::apt_conf_d
-
-  file { "${apt_conf_d}/${priority}${name}":
-    ensure  => $ensure,
-    content => template('apt/_header.erb', 'apt/conf.erb'),
-    owner   => root,
-    group   => root,
-    mode    => '0644',
+  apt::setting { "conf-${name}":
+    ensure   => $ensure,
+    priority => $priority,
+    content  => template('apt/_header.erb', 'apt/conf.erb'),
   }
 }
diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp
deleted file mode 100644 (file)
index 7af48d2..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# testing.pp
-
-class apt::debian::testing {
-  include apt
-
-  # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
-  # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
-  # Key: 46925553  Server: subkeys.pgp.net
-  # debian-keyring
-  # debian-archive-keyring
-
-  apt::source { 'debian_testing':
-    location          => 'http://debian.mirror.iweb.ca/debian/',
-    release           => 'testing',
-    repos             => 'main contrib non-free',
-    required_packages => 'debian-keyring debian-archive-keyring',
-    key               => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-    key_server        => 'subkeys.pgp.net',
-    pin               => '-10',
-  }
-}
diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp
deleted file mode 100644 (file)
index 23ce9b4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# unstable.pp
-
-class apt::debian::unstable {
-  include apt
-
-  # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
-  # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
-  # Key: 46925553  Server: subkeys.pgp.net
-  # debian-keyring
-  # debian-archive-keyring
-
-  apt::source { 'debian_unstable':
-    location          => 'http://debian.mirror.iweb.ca/debian/',
-    release           => 'unstable',
-    repos             => 'main contrib non-free',
-    required_packages => 'debian-keyring debian-archive-keyring',
-    key               => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-    key_server        => 'subkeys.pgp.net',
-    pin               => '-10',
-  }
-}
diff --git a/manifests/force.pp b/manifests/force.pp
deleted file mode 100644 (file)
index 8ceeb17..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-# force.pp
-# force a package from a specific release
-
-define apt::force(
-  $release     = false,
-  $version     = false,
-  $timeout     = 300,
-  $cfg_files   = 'none',
-  $cfg_missing = false,
-) {
-
-  validate_re($cfg_files, ['^new', '^old', '^unchanged', '^none'])
-  validate_bool($cfg_missing)
-
-  $provider = $apt::params::provider
-
-  $version_string = $version ? {
-    false   => undef,
-    default => "=${version}",
-  }
-
-  $release_string = $release ? {
-    false   => undef,
-    default => "-t ${release}",
-  }
-
-  case $cfg_files {
-    'new':           { $config_files = '-o Dpkg::Options::="--force-confnew"' }
-    'old':           { $config_files = '-o Dpkg::Options::="--force-confold"' }
-    'unchanged':     { $config_files = '-o Dpkg::Options::="--force-confdef"' }
-    'none', default: { $config_files = '' }
-  }
-
-  case $cfg_missing {
-    true:           { $config_missing = '-o Dpkg::Options::="--force-confmiss"' }
-    false, default: { $config_missing = '' }
-  }
-
-  if $version == false {
-    if $release == false {
-      $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'"
-    } else {
-      # If installed version and candidate version differ, this check returns 1 (false).
-      $install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
-    }
-  } else {
-    if $release == false {
-      $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'"
-    } else {
-      $install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'"
-    }
-  }
-
-  exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}":
-    unless      => $install_check,
-    environment => ['LC_ALL=C', 'LANG=C'],
-    logoutput   => 'on_failure',
-    timeout     => $timeout,
-  }
-}
diff --git a/manifests/hold.pp b/manifests/hold.pp
deleted file mode 100644 (file)
index 61e8afc..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-# == Define apt::hold
-#
-# This defined type allows you to hold a package based on the version you
-# require. It's implemented by dropping an apt preferences file pinning the
-# package to the version you require.
-#
-# === Parameters
-#
-# [*version*]
-#   The version at which you wish to pin a package.
-#
-#   This can either be the full version, such as 4:2.11.8.1-5, or
-#   a partial version, such as 4:2.11.*
-#
-# [*package*]
-#   _default_: +$title+, the title/name of the resource.
-#
-#   Name of the package that apt is to hold.
-#
-# [*priority*]
-#   _default_: +1001+
-#
-#   The default priority of 1001 causes this preference to always win. By
-#   setting the priority to a number greater than 1000 apt will always install
-#   this version even if it means downgrading the currently installed version.
-define apt::hold(
-  $version,
-  $ensure   = 'present',
-  $package  = $title,
-  $priority = 1001,
-){
-
-  validate_string($title)
-  validate_re($ensure, ['^present|absent',])
-  validate_string($package)
-  validate_string($version)
-
-  if ! is_integer($priority) {
-    fail('$priority must be an integer')
-  }
-
-  if $ensure == 'present' {
-    ::apt::pin { "hold_${package}":
-      packages => $package,
-      version  => $version,
-      priority => $priority,
-    }
-  } else {
-    ::apt::pin { "hold_${package}":
-      ensure => 'absent',
-    }
-  }
-
-}
index 5f33fdba703920ddf94d2ea540ffc4ef2ed3497c..140e171c50b008cb8f57d8596cfe77ca8f958476 100644 (file)
-# == Class: apt
-#
-# This module manages the initial configuration of apt.
-#
-# The parameters listed here are not required in general and were
-# added for use cases related to development environments.
-#
-# === Parameters
-#
-# [*disable_keys*]
-#   Disables the requirement for all packages to be signed
-#
-# [*always_apt_update*]
-#   Rather apt should be updated on every run (intended
-#   for development environments where package updates are frequent)
-#
-# [*apt_update_frequency*]
-#   String: Supported values:
-#   **always**: Will fire `apt-get update` at every puppet run. Intended to
-#       deprecate the `always_apt_update` parameter.
-#   *daily**: Trigger `apt-get update` if the value of the fact
-#       `apt_update_last_success` is less than current epoch time - 86400.
-#        *notifying the apt_update exec will trigger apt-get update regardless*
-#   *weekly**: Trigger `apt-get update` if the value of the fact
-#       `apt_update_last_success` is less than current epoch time - 604800.
-#        *notifying the apt_update exec will trigger apt-get update regardless*
-#   *reluctantly**: *Default* only run apt-get update if the exec resource `apt_update` is notified.
-#
-# [*purge_sources_list*]
-#   Accepts true or false. Defaults to false If set to
-#   true, Puppet will purge all unmanaged entries from sources.list
-#
-# [*purge_sources_list_d*]
-#   Accepts true or false. Defaults to false. If set
-#   to true, Puppet will purge all unmanaged entries from sources.list.d
-#
-# [*update_timeout*]
-#   Overrides the exec timeout in seconds for apt-get update.
-#   If not set defaults to Exec's default (300)
-#
-# [*update_tries*]
-#   Number of times that `apt-get update` will be tried. Use this
-#   to work around transient DNS and HTTP errors. By default, the command
-#   will only be run once.
-#
-# === Examples
-#
-# class { 'apt': }
-#
-# === Requires
-#
-# puppetlabs/stdlib >= 2.2.1
 #
 class apt(
-  $always_apt_update    = false,
-  $apt_update_frequency = 'reluctantly',
-  $disable_keys         = undef,
-  $proxy_host           = undef,
-  $proxy_port           = '8080',
-  $purge_sources_list   = false,
-  $purge_sources_list_d = false,
-  $purge_preferences    = false,
-  $purge_preferences_d  = false,
-  $update_timeout       = undef,
-  $update_tries         = undef,
-  $sources              = undef,
-  $fancy_progress       = undef
-) {
-
-  if $::osfamily != 'Debian' {
-    fail('This module only works on Debian or derivatives like Ubuntu')
-  }
+  $update   = {},
+  $purge    = {},
+  $proxy    = {},
+  $sources  = {},
+  $keys     = {},
+  $ppas     = {},
+  $settings = {},
+) inherits ::apt::params {
 
   $frequency_options = ['always','daily','weekly','reluctantly']
-  validate_re($apt_update_frequency, $frequency_options)
-  include apt::params
+  validate_hash($update)
+  if $update['frequency'] {
+    validate_re($update['frequency'], $frequency_options)
+  }
+  if $update['timeout'] {
+    unless is_integer($update['timeout']) {
+      fail('timeout value for update must be an integer')
+    }
+  }
+  if $update['tries'] {
+    unless is_integer($update['tries']) {
+      fail('tries value for update must be an integer')
+    }
+  }
+
+  $_update = merge($::apt::update_defaults, $update)
   include apt::update
 
-  validate_bool($purge_sources_list, $purge_sources_list_d,
-                $purge_preferences, $purge_preferences_d)
+  validate_hash($purge)
+  if $purge['sources.list'] {
+    validate_bool($purge['sources.list'])
+  }
+  if $purge['sources.list.d'] {
+    validate_bool($purge['sources.list.d'])
+  }
+  if $purge['preferences'] {
+    validate_bool($purge['preferences'])
+  }
+  if $purge['preferences.d'] {
+    validate_bool($purge['preferences.d'])
+  }
+
+  $_purge = merge($::apt::purge_defaults, $purge)
+
+  validate_hash($proxy)
+  if $proxy['host'] {
+    validate_string($proxy['host'])
+  }
+  if $proxy['port'] {
+    unless is_integer($proxy['port']) {
+      fail('$proxy port must be an integer')
+    }
+  }
+  if $proxy['https'] {
+    validate_bool($proxy['https'])
+  }
+
+  $_proxy = merge($apt::proxy_defaults, $proxy)
+
+  validate_hash($sources)
+  validate_hash($keys)
+  validate_hash($settings)
+  validate_hash($ppas)
+
+  if $proxy['host'] {
+    apt::setting { 'conf-proxy':
+      priority => '01',
+      content  => template('apt/_header.erb', 'apt/proxy.erb'),
+    }
+  }
 
-  $sources_list_content = $purge_sources_list ? {
+  $sources_list_content = $_purge['sources.list'] ? {
     false => undef,
     true  => "# Repos managed by puppet.\n",
   }
 
-  if $always_apt_update == true {
+  $preferences_ensure = $_purge['preferences'] ? {
+    false => file,
+    true  => absent,
+  }
+
+  if $_update['frequency'] == 'always' {
     Exec <| title=='apt_update' |> {
       refreshonly => false,
     }
   }
 
-  file { '/etc/apt/apt.conf.d/15update-stamp':
-    ensure  => 'file',
-    content => template('apt/_header.erb', 'apt/15update-stamp.erb'),
-    group   => 'root',
-    mode    => '0644',
-    owner   => 'root',
+  apt::setting { 'conf-update-stamp':
+    priority => 15,
+    content  => template('apt/_header.erb', 'apt/15update-stamp.erb'),
   }
 
-  $root           = $apt::params::root
-  $apt_conf_d     = $apt::params::apt_conf_d
-  $sources_list_d = $apt::params::sources_list_d
-  $preferences_d  = $apt::params::preferences_d
-  $provider       = $apt::params::provider
-
   file { 'sources.list':
-    ensure  => present,
-    path    => "${root}/sources.list",
+    ensure  => file,
+    path    => $::apt::sources_list,
     owner   => root,
     group   => root,
     mode    => '0644',
@@ -116,101 +104,51 @@ class apt(
 
   file { 'sources.list.d':
     ensure  => directory,
-    path    => $sources_list_d,
+    path    => $::apt::sources_list_d,
     owner   => root,
     group   => root,
-    purge   => $purge_sources_list_d,
-    recurse => $purge_sources_list_d,
+    mode    => '0644',
+    purge   => $_purge['sources.list.d'],
+    recurse => $_purge['sources.list.d'],
     notify  => Exec['apt_update'],
   }
 
-  if $purge_preferences {
-    file { 'apt-preferences':
-      ensure => absent,
-      path   => "${root}/preferences",
-    }
+  file { 'preferences':
+    ensure => $preferences_ensure,
+    path   => $::apt::preferences,
+    owner  => root,
+    group  => root,
+    mode   => '0644',
+    notify => Exec['apt_update'],
   }
 
   file { 'preferences.d':
     ensure  => directory,
-    path    => $preferences_d,
+    path    => $::apt::preferences_d,
     owner   => root,
     group   => root,
-    purge   => $purge_preferences_d,
-    recurse => $purge_preferences_d,
-  }
-
-  case $fancy_progress {
-    true: {
-      file { '99progressbar':
-        ensure  => present,
-        content => template('apt/_header.erb', 'apt/progressbar.erb'),
-        path    => "${apt_conf_d}/99progressbar",
-      }
-    }
-    false: {
-      file { '99progressbar':
-        ensure => absent,
-        path   => "${apt_conf_d}/99progressbar",
-      }
-    }
-    undef: {} # do nothing
-    default: { fail('Valid values for fancy_progress are true or false') }
+    mode    => '0644',
+    purge   => $_purge['preferences.d'],
+    recurse => $_purge['preferences.d'],
+    notify  => Exec['apt_update'],
   }
 
-  case $disable_keys {
-    true: {
-      file { '99unauth':
-        ensure  => present,
-        content => template('apt/_header.erb', 'apt/unauth.erb'),
-        path    => "${apt_conf_d}/99unauth",
-      }
-    }
-    false: {
-      file { '99unauth':
-        ensure => absent,
-        path   => "${apt_conf_d}/99unauth",
-      }
-    }
-    undef:   { } # do nothing
-    default: { fail('Valid values for disable_keys are true or false') }
-  }
+  contain 'apt::update'
 
-  case $proxy_host {
-    false, '', undef: {
-      file { '01proxy':
-        ensure => absent,
-        path   => "${apt_conf_d}/01proxy",
-        notify => Exec['apt_update'],
-      }
-    }
-    default: {
-      file { '01proxy':
-        ensure  => present,
-        path    => "${apt_conf_d}/01proxy",
-        content => template('apt/_header.erb', 'apt/proxy.erb'),
-        notify  => Exec['apt_update'],
-        mode    => '0644',
-        owner   => root,
-        group   => root,
-      }
-    }
+  # manage sources if present
+  if $sources {
+    create_resources('apt::source', $sources)
   }
-
-  file { 'old-proxy-file':
-    ensure => absent,
-    path   => "${apt_conf_d}/proxy",
-    notify => Exec['apt_update'],
+  # manage keys if present
+  if $keys {
+    create_resources('apt::key', $keys)
   }
-
-  # Need anchor to provide containment for dependencies.
-  anchor { 'apt::update':
-    require => Class['apt::update'],
+  # manage ppas if present
+  if $ppas {
+    create_resources('apt::ppa', $ppas)
   }
-
-  # manage sources if present
-  if $sources != undef {
-    validate_hash($sources)
-    create_resources('apt::source', $sources)
+  # manage settings if present
+  if $settings {
+    create_resources('apt::setting', $settings)
   }
 }
index ce5fc2514cee6c27d32be04cd0cdaf3f47dac359..6761e6912d31a253fd969c0dd4c5a48d8679e964 100644 (file)
@@ -7,7 +7,7 @@
 #
 # === Parameters
 #
-# [*key*]
+# [*id*]
 #   _default_: +$title+, the title/name of the resource
 #
 #   Is a GPG key ID or full key fingerprint. This value is validated with
 #   * +present+
 #   * +absent+
 #
-# [*key_content*]
+# [*content*]
 #   _default_: +undef+
 #
 #   This parameter can be used to pass in a GPG key as a
 #   string in case it cannot be fetched from a remote location
 #   and using a file resource is for other reasons inconvenient.
 #
-# [*key_source*]
+# [*source*]
 #   _default_: +undef+
 #
 #   This parameter can be used to pass in the location of a GPG
 #   * +URL+: ftp, http or https
 #   * +path+: absolute path to a file on the target system.
 #
-# [*key_server*]
+# [*server*]
 #   _default_: +undef+
 #
 #   The keyserver from where to fetch our GPG key. It can either be a domain
-#   name or url. It defaults to
-#   undef which results in apt_key's default keyserver being used,
-#   currently +keyserver.ubuntu.com+.
+#   name or url. It defaults to +keyserver.ubuntu.com+.
 #
-# [*key_options*]
+# [*options*]
 #   _default_: +undef+
 #
 #   Additional options to pass on to `apt-key adv --keyserver-options`.
 define apt::key (
-  $key         = $title,
-  $ensure      = present,
-  $key_content = undef,
-  $key_source  = undef,
-  $key_server  = undef,
-  $key_options = undef,
+  $id      = $title,
+  $ensure  = present,
+  $content = undef,
+  $source  = undef,
+  $server  = $::apt::keyserver,
+  $options = undef,
 ) {
 
-  validate_re($key, ['\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($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
   validate_re($ensure, ['\Aabsent|present\Z',])
 
-  if $key_content {
-    validate_string($key_content)
+  if $content {
+    validate_string($content)
   }
 
-  if $key_source {
-    validate_re($key_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
+  if $source {
+    validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
   }
 
-  if $key_server {
-    validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
+  if $server {
+    validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
   }
 
-  if $key_options {
-    validate_string($key_options)
+  if $options {
+    validate_string($options)
   }
 
   case $ensure {
     present: {
-      if defined(Anchor["apt_key ${key} absent"]){
-        fail("key with id ${key} 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 ${key} present"]) {
+      if !defined(Anchor["apt_key ${id} present"]) {
         apt_key { $title:
-          ensure            => $ensure,
-          id                => $key,
-          source            => $key_source,
-          content           => $key_content,
-          server            => $key_server,
-          keyserver_options => $key_options,
+          ensure  => $ensure,
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
         } ->
-        anchor { "apt_key ${key} present": }
+        anchor { "apt_key ${id} present": }
       }
     }
 
     absent: {
-      if defined(Anchor["apt_key ${key} present"]){
-        fail("key with id ${key} 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 ${key} absent"]){
+      if !defined(Anchor["apt_key ${id} absent"]){
         apt_key { $title:
-          ensure            => $ensure,
-          id                => $key,
-          source            => $key_source,
-          content           => $key_content,
-          server            => $key_server,
-          keyserver_options => $key_options,
+          ensure  => $ensure,
+          id      => $id,
+          source  => $source,
+          content => $content,
+          server  => $server,
+          options => $options,
         } ->
-        anchor { "apt_key ${key} absent": }
+        anchor { "apt_key ${id} absent": }
       }
     }
 
index 4efe872e5b6f34db7dbdb943199f5cd97c2d4b92..57cee5007d65ee75a21f06c4a6afa4ec315db807 100644 (file)
 class apt::params {
+
+  if $::osfamily != 'Debian' {
+    fail('This module only works on Debian or derivatives like Ubuntu')
+  }
+
+  # Strict variables facts lookup compatibility
+  $xfacts = {
+    'lsbdistcodename' => defined('$lsbdistcodename') ? {
+      true    => $::lsbdistcodename,
+      default => undef,
+    },
+    'lsbdistrelease' => defined('$lsbdistrelease') ? {
+      true    => $::lsbdistrelease,
+      default => undef,
+    },
+    'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? {
+      true    => $::lsbmajdistrelease,
+      default => undef,
+    },
+    'lsbdistdescription' => defined('$lsbdistdescription') ? {
+      true    => $::lsbdistdescription,
+      default => undef,
+    },
+    'lsbminordistrelease' => defined('$lsbminordistrelease') ? {
+      true    => $::lsbminordistrelease,
+      default => undef,
+    },
+    'lsbdistid' => defined('$lsbdistid') ? {
+      true    => $::lsbdistid,
+      default => undef,
+    },
+  }
+
   $root           = '/etc/apt'
   $provider       = '/usr/bin/apt-get'
+  $sources_list   = "${root}/sources.list"
   $sources_list_d = "${root}/sources.list.d"
-  $apt_conf_d     = "${root}/apt.conf.d"
+  $conf_d         = "${root}/apt.conf.d"
+  $preferences    = "${root}/preferences"
   $preferences_d  = "${root}/preferences.d"
+  $keyserver      = 'keyserver.ubuntu.com'
+
+  $config_files = {
+    'conf'   => {
+      'path' => $conf_d,
+      'ext'  => '',
+    },
+    'pref'   => {
+      'path' => $preferences_d,
+      'ext'  => '',
+    },
+    'list'   => {
+      'path' => $sources_list_d,
+      'ext'  => '.list',
+    }
+  }
+
+  $update_defaults = {
+    'frequency' => 'reluctantly',
+    'timeout'   => undef,
+    'tries'     => undef,
+  }
+
+  $proxy_defaults = {
+    'host'  => undef,
+    'port'  => 8080,
+    'https' => false,
+  }
+
+  $purge_defaults = {
+    'sources.list'   => true,
+    'sources.list.d' => true,
+    'preferences'    => true,
+    'preferences.d'  => true,
+  }
 
-  case $::lsbdistid {
+  $source_key_defaults = {
+    'server'  => $keyserver,
+    'options' => undef,
+    'content' => undef,
+    'source'  => undef,
+  }
+
+  $include_defaults = {
+    'deb' => true,
+    'src' => false,
+  }
+
+  case $xfacts['lsbdistid'] {
     'ubuntu', 'debian': {
-      $distid = $::lsbdistid
-      $distcodename = $::lsbdistcodename
+      $distid = $xfacts['lsbdistid']
+      $distcodename = $xfacts['lsbdistcodename']
     }
     'linuxmint': {
-      if $::lsbdistcodename == 'debian' {
+      if $xfacts['lsbdistcodename'] == 'debian' {
         $distid = 'debian'
         $distcodename = 'wheezy'
       } else {
         $distid = 'ubuntu'
-        $distcodename = $::lsbdistcodename ? {
+        $distcodename = $xfacts['lsbdistcodename'] ? {
           'qiana'  => 'trusty',
           'petra'  => 'saucy',
           'olivia' => 'raring',
@@ -29,7 +111,7 @@ class apt::params {
       $distid = 'debian'
       $distcodename = $::lsbdistcodename
     }
-    '': {
+    undef: {
       fail('Unable to determine lsbdistid, is lsb-release installed?')
     }
     default: {
@@ -37,59 +119,29 @@ class apt::params {
     }
   }
   case $distid {
-    'debian': {
-      case $distcodename {
-        'squeeze': {
-          $backports_location = 'http://backports.debian.org/debian-backports'
-          $legacy_origin       = true
-          $origins             = ['${distro_id} oldstable', #lint:ignore:single_quote_string_with_variables
-                                  '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables
-                                  '${distro_id} ${distro_codename}-lts'] #lint:ignore:single_quote_string_with_variables
-        }
-        'wheezy': {
-          $backports_location = 'http://ftp.debian.org/debian/'
-          $legacy_origin      = false
-          $origins            = ['origin=Debian,archive=stable,label=Debian-Security',
-                                  'origin=Debian,archive=oldstable,label=Debian-Security']
-        }
-        default: {
-          $backports_location = 'http://http.debian.net/debian/'
-          $legacy_origin      = false
-          $origins            = ['origin=Debian,archive=stable,label=Debian-Security']
-        }
-      }
-    }
     'ubuntu': {
       case $distcodename {
         'lucid': {
-          $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = undef
           $ppa_package        = 'python-software-properties'
-          $legacy_origin      = true
-          $origins            = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
         'precise': {
-          $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = '-y'
           $ppa_package        = 'python-software-properties'
-          $legacy_origin      = true
-          $origins            = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
         'trusty', 'utopic', 'vivid': {
-          $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = '-y'
           $ppa_package        = 'software-properties-common'
-          $legacy_origin      = true
-          $origins            = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
         default: {
-          $backports_location = 'http://old-releases.ubuntu.com/ubuntu'
           $ppa_options        = '-y'
           $ppa_package        = 'python-software-properties'
-          $legacy_origin      = true
-          $origins            = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
       }
     }
+    '', default: {
+      $ppa_options = undef
+      $ppa_package = undef
+    }
   }
 }
index 935dc226e55bdffb7adebefec965d7b4935859c1..bcccf28b7c8058532e30827c172a58f0f171bc1b 100644 (file)
@@ -3,8 +3,8 @@
 
 define apt::pin(
   $ensure          = present,
-  $explanation     = "${caller_module_name}: ${name}",
-  $order           = '',
+  $explanation     = undef,
+  $order           = undef,
   $packages        = '*',
   $priority        = 0,
   $release         = '', # a=
@@ -16,14 +16,20 @@ define apt::pin(
   $originator      = '', # o=
   $label           = ''  # l=
 ) {
-  include apt::params
-
-  $preferences_d = $apt::params::preferences_d
-
-  if $order != '' and !is_integer($order) {
+  if $order and !is_integer($order) {
     fail('Only integers are allowed in the apt::pin order param')
   }
 
+  if $explanation {
+    $_explanation = $explanation
+  } else {
+    if defined('$caller_module_name') { # strict vars check
+      $_explanation = "${caller_module_name}: ${name}"
+    } else {
+      $_explanation = ": ${name}"
+    }
+  }
+
   $pin_release_array = [
     $release,
     $codename,
@@ -56,7 +62,6 @@ define apt::pin(
     }
   }
 
-
   # According to man 5 apt_preferences:
   # The files have either no or "pref" as filename extension
   # and only contain alphanumeric, hyphen (-), underscore (_) and period
@@ -66,16 +71,9 @@ define apt::pin(
   # be silently ignored.
   $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
 
-  $path = $order ? {
-    ''      => "${preferences_d}/${file_name}.pref",
-    default => "${preferences_d}/${order}-${file_name}.pref",
-  }
-  file { "${file_name}.pref":
-    ensure  => $ensure,
-    path    => $path,
-    owner   => root,
-    group   => root,
-    mode    => '0644',
-    content => template('apt/_header.erb', 'apt/pin.pref.erb'),
+  apt::setting { "pref-${file_name}":
+    ensure   => $ensure,
+    priority => $order,
+    content  => template('apt/_header.erb', 'apt/pin.pref.erb'),
   }
 }
index e86a19fd9d32216f1c1f3a85a0e3f04fb050cb2e..5d4c8903d5c6d9968c64e255f63cc61466554326 100644 (file)
@@ -1,23 +1,17 @@
 # ppa.pp
-
 define apt::ppa(
   $ensure         = 'present',
-  $release        = $::lsbdistcodename,
-  $options        = $::apt::params::ppa_options,
-  $package_name   = $::apt::params::ppa_package,
-  $package_manage = true,
+  $options        = $::apt::ppa_options,
+  $release        = $::apt::xfacts['lsbdistcodename'],
+  $package_name   = $::apt::ppa_package,
+  $package_manage = false,
 ) {
-  include apt::params
-  include apt::update
-
-  $sources_list_d = $apt::params::sources_list_d
-
-  if ! $release {
+  unless $release {
     fail('lsbdistcodename fact not available: release parameter required')
   }
 
-  if $::operatingsystem != 'Ubuntu' {
-    fail('apt::ppa is currently supported on Ubuntu only.')
+  if $::apt::distid != 'ubuntu' {
+    fail('apt::ppa is currently supported on Ubuntu and LinuxMint only.')
   }
 
   $filename_without_slashes = regsubst($name, '/', '-', 'G')
@@ -27,52 +21,43 @@ define apt::ppa(
 
   if $ensure == 'present' {
     if $package_manage {
-      if ! defined(Package[$package_name]) {
-        package { $package_name: }
-      }
+      package { $package_name: }
 
       $_require = [File['sources.list.d'], Package[$package_name]]
     } else {
       $_require = File['sources.list.d']
     }
 
-    if defined(Class['apt']) {
-      case $::apt::proxy_host {
-        false, '', undef: {
-          $proxy_env = []
-        }
-        default: {
-          $proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"]
-        }
+    $_proxy = $::apt::_proxy
+    if $_proxy['host'] {
+      if $_proxy['https'] {
+        $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=https://${_proxy['host']}:${_proxy['port']}"]
+      } else {
+        $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}"]
       }
     } else {
-      $proxy_env = []
+      $_proxy_env = []
     }
 
     exec { "add-apt-repository-${name}":
-      environment => $proxy_env,
+      environment => $_proxy_env,
       command     => "/usr/bin/add-apt-repository ${options} ${name}",
-      unless      => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
+      unless      => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}",
       user        => 'root',
       logoutput   => 'on_failure',
       notify      => Exec['apt_update'],
       require     => $_require,
     }
 
-    file { "${sources_list_d}/${sources_list_d_filename}":
+    file { "${::apt::sources_list_d}/${sources_list_d_filename}":
       ensure  => file,
       require => Exec["add-apt-repository-${name}"],
     }
   }
   else {
-    file { "${sources_list_d}/${sources_list_d_filename}":
+    file { "${::apt::sources_list_d}/${sources_list_d_filename}":
       ensure => 'absent',
       notify => Exec['apt_update'],
     }
   }
-
-  # Need anchor to provide containment for dependencies.
-  anchor { "apt::ppa::${name}":
-    require => Class['apt::update'],
-  }
 }
diff --git a/manifests/release.pp b/manifests/release.pp
deleted file mode 100644 (file)
index ae12dd4..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# release.pp
-
-class apt::release (
-  $release_id
-) {
-
-  include apt::params
-
-  $root = $apt::params::root
-
-  file { "${root}/apt.conf.d/01release":
-    owner   => root,
-    group   => root,
-    mode    => '0644',
-    content => template('apt/_header.erb', 'apt/release.erb'),
-  }
-}
diff --git a/manifests/setting.pp b/manifests/setting.pp
new file mode 100644 (file)
index 0000000..ab84460
--- /dev/null
@@ -0,0 +1,63 @@
+define apt::setting (
+  $priority      = 50,
+  $ensure        = file,
+  $source        = undef,
+  $content       = undef,
+  $notify_update = true,
+) {
+
+  if $content and $source {
+    fail('apt::setting cannot have both content and source')
+  }
+
+  if !$content and !$source {
+    fail('apt::setting needs either of content or source')
+  }
+
+  validate_re($ensure,  ['file', 'present', 'absent'])
+  validate_bool($notify_update)
+
+  $title_array = split($title, '-')
+  $setting_type = $title_array[0]
+  $base_name = join(delete_at($title_array, 0), '-')
+
+  validate_re($setting_type, ['\Aconf\z', '\Apref\z', '\Alist\z'], "apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'")
+
+  unless is_integer($priority) {
+    # need this to allow zero-padded priority.
+    validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer')
+  }
+
+  if $source {
+    validate_string($source)
+  }
+
+  if $content {
+    validate_string($content)
+  }
+
+  if $setting_type == 'list' {
+    $_priority = ''
+  } else {
+    $_priority = $priority
+  }
+
+  $_path = $::apt::config_files[$setting_type]['path']
+  $_ext  = $::apt::config_files[$setting_type]['ext']
+
+  if $notify_update {
+    $_notify = Exec['apt_update']
+  } else {
+    $_notify = undef
+  }
+
+  file { "${_path}/${_priority}${base_name}${_ext}":
+    ensure  => $ensure,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    content => $content,
+    source  => $source,
+    notify  => $_notify,
+  }
+}
index f6647dfe76b1021e645871711d6a8e9a11b6af57..163a411bb21f426f1ae1f43aeeffc4cd4c188464 100644 (file)
@@ -1,54 +1,49 @@
 # source.pp
 # add an apt source
-
 define apt::source(
-  $comment           = $name,
-  $ensure            = present,
-  $location          = '',
-  $release           = 'UNDEF',
-  $repos             = 'main',
-  $include_src       = true,
-  $include_deb       = true,
-  $required_packages = false,
-  $key               = undef,
-  $key_server        = 'keyserver.ubuntu.com',
-  $key_content       = undef,
-  $key_source        = undef,
-  $pin               = false,
-  $architecture      = undef,
-  $trusted_source    = false,
+  $location       = undef,
+  $comment        = $name,
+  $ensure         = present,
+  $release        = $::apt::xfacts['lsbdistcodename'],
+  $repos          = 'main',
+  $include        = {},
+  $key            = undef,
+  $pin            = false,
+  $architecture   = undef,
+  $allow_unsigned = false,
 ) {
+  validate_string($architecture, $comment, $location, $repos)
+  validate_bool($allow_unsigned)
+  validate_hash($include)
 
-  include apt::params
-  include apt::update
+  unless $release {
+    fail('lsbdistcodename fact not available: release parameter required')
+  }
 
-  validate_string($architecture)
-  validate_bool($trusted_source)
+  if $ensure == 'present' and ! $location {
+    fail('cannot create a source entry without specifying a location')
+  }
 
-  $sources_list_d = $apt::params::sources_list_d
-  $provider       = $apt::params::provider
+  $_before = Apt::Setting["list-${title}"]
+  $_include = merge($::apt::include_defaults, $include)
 
-  if $release == 'UNDEF' {
-    if $::lsbdistcodename == undef {
-      fail('lsbdistcodename fact not available: release parameter required')
+  if $key {
+    if is_hash($key) {
+      unless $key['id'] {
+        fail('key hash must contain at least an id entry')
+      }
+      $_key = merge($::apt::source_key_defaults, $key)
     } else {
-      $release_real = $::lsbdistcodename
+      validate_string($key)
+      $_key = $key
     }
-  } else {
-    $release_real = $release
   }
 
-  file { "${name}.list":
+  apt::setting { "list-${name}":
     ensure  => $ensure,
-    path    => "${sources_list_d}/${name}.list",
-    owner   => root,
-    group   => root,
-    mode    => '0644',
     content => template('apt/_header.erb', 'apt/source.list.erb'),
-    notify  => Exec['apt_update'],
   }
 
-
   if ($pin != false) {
     # Get the host portion out of the url so we can pin to origin
     $url_split = split($location, '/')
@@ -57,37 +52,29 @@ define apt::source(
     apt::pin { $name:
       ensure   => $ensure,
       priority => $pin,
-      before   => File["${name}.list"],
+      before   => $_before,
       origin   => $host,
     }
   }
 
-  if ($required_packages != false) and ($ensure == 'present') {
-    exec { "Required packages: '${required_packages}' for ${name}":
-      command     => "${provider} -y install ${required_packages}",
-      logoutput   => 'on_failure',
-      refreshonly => true,
-      tries       => 3,
-      try_sleep   => 1,
-      subscribe   => File["${name}.list"],
-      before      => Exec['apt_update'],
-    }
-  }
-
   # We do not want to remove keys when the source is absent.
   if $key and ($ensure == 'present') {
-    apt::key { "Add key: ${key} from Apt::Source ${title}":
-      ensure      => present,
-      key         => $key,
-      key_server  => $key_server,
-      key_content => $key_content,
-      key_source  => $key_source,
-      before      => File["${name}.list"],
+    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'],
+        before  => $_before,
+      }
+    } else {
+      apt::key { "Add key: ${_key} from Apt::Source ${title}":
+        ensure => present,
+        id     => $_key,
+        before => $_before,
+      }
     }
   }
-
-  # Need anchor to provide containment for dependencies.
-  anchor { "apt::source::${name}":
-    require => Class['apt::update'],
-  }
 }
diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp
deleted file mode 100644 (file)
index 028ffc6..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-# Class: apt::unattended_upgrades
-#
-# This class manages the unattended-upgrades package and related configuration
-# files for ubuntu
-#
-# origins are the repositories to automatically upgrade included packages
-# blacklist is a list of packages to not automatically upgrade
-# update is how often to run "apt-get update" in days
-# download is how often to run "apt-get upgrade --download-only" in days
-# upgrade is how often to upgrade packages included in the origins list in days
-# autoclean is how often to run "apt-get autoclean" in days
-#
-# information on the other options can be found in the 50unattended-upgrades
-# file and in /etc/cron.daily/apt
-#
-class apt::unattended_upgrades (
-  $legacy_origin       = $::apt::params::legacy_origin,
-  $origins             = $::apt::params::origins,
-  $blacklist           = [],
-  $update              = '1',
-  $download            = '1',
-  $upgrade             = '1',
-  $autoclean           = '7',
-  $auto_fix            = true,
-  $minimal_steps       = false,
-  $install_on_shutdown = false,
-  $mail_to             = 'NONE',
-  $mail_only_on_error  = false,
-  $remove_unused       = true,
-  $auto_reboot         = false,
-  $dl_limit            = 'NONE',
-  $randomsleep         = undef,
-  $enable              = '1',
-  $backup_interval     = '0',
-  $backup_level        = '3',
-  $max_age             = '0',
-  $min_age             = '0',
-  $max_size            = '0',
-  $download_delta      = '0',
-  $verbose             = '0',
-) inherits ::apt::params {
-
-  validate_bool(
-    $legacy_origin,
-    $auto_fix,
-    $minimal_steps,
-    $install_on_shutdown,
-    $mail_only_on_error,
-    $remove_unused,
-    $auto_reboot
-  )
-  validate_array($origins)
-
-  if $randomsleep {
-    unless is_numeric($randomsleep) {
-      fail('randomsleep must be numeric')
-    }
-  }
-
-  package { 'unattended-upgrades':
-    ensure => present,
-  }
-
-  file { '/etc/apt/apt.conf.d/50unattended-upgrades':
-    ensure  => file,
-    owner   => 'root',
-    group   => 'root',
-    mode    => '0644',
-    content => template('apt/_header.erb', 'apt/50unattended-upgrades.erb'),
-    require => Package['unattended-upgrades'],
-  }
-
-  file { '/etc/apt/apt.conf.d/10periodic':
-    ensure  => file,
-    owner   => 'root',
-    group   => 'root',
-    mode    => '0644',
-    content => template('apt/_header.erb', 'apt/10periodic.erb'),
-    require => Package['unattended-upgrades'],
-  }
-}
index d9b338d952a23bfef373dd987d151ef8a2467fab..86f068200c7890d4e59d77ba250ff1cc9096b4bb 100644 (file)
@@ -1,55 +1,48 @@
 class apt::update {
-  include apt::params
   #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we
   #opt to do this, a info/warn would likely be all you'd need likely to happen
   #on the first run, but if it's not run in awhile something is likely borked
   #with apt and we'd want to know about it.
 
-  if $::apt::always_apt_update == false {
-    #if always_apt_update is true there's no point in parsing this logic.
-
-    case $apt::apt_update_frequency {
-      'always': {
-        $_kick_apt = true
-      }
-      'daily': {
-        #compare current date with the apt_update_last_success fact to determine
-        #if we should kick apt_update.
-        $daily_threshold = (strftime('%s') - 86400)
-        if $::apt_update_last_success {
-          if $::apt_update_last_success < $daily_threshold {
-            $_kick_apt = true
-          } else {
-            $_kick_apt = false
-          }
-        } else {
-          #if apt-get update has not successfully run, we should kick apt_update
+  case $::apt::_update['frequency'] {
+    'always': {
+      $_kick_apt = true
+    }
+    'daily': {
+      #compare current date with the apt_update_last_success fact to determine
+      #if we should kick apt_update.
+      $daily_threshold = (strftime('%s') - 86400)
+      if $::apt_update_last_success {
+        if $::apt_update_last_success < $daily_threshold {
           $_kick_apt = true
+        } else {
+          $_kick_apt = false
         }
+      } else {
+        #if apt-get update has not successfully run, we should kick apt_update
+        $_kick_apt = true
       }
-      'weekly':{
-        #compare current date with the apt_update_last_success fact to determine
-        #if we should kick apt_update.
-        $weekly_threshold = (strftime('%s') - 604800)
-        if $::apt_update_last_success {
-          if ( $::apt_update_last_success < $weekly_threshold ) {
-            $_kick_apt = true
-          } else {
-            $_kick_apt = false
-          }
-        } else {
-          #if apt-get update has not successfully run, we should kick apt_update
+    }
+    'weekly':{
+      #compare current date with the apt_update_last_success fact to determine
+      #if we should kick apt_update.
+      $weekly_threshold = (strftime('%s') - 604800)
+      if $::apt_update_last_success {
+        if ( $::apt_update_last_success < $weekly_threshold ) {
           $_kick_apt = true
+        } else {
+          $_kick_apt = false
         }
-      }
-      default: {
-        #catches 'recluctantly', and any other value (which should not occur).
-        #do nothing.
-        $_kick_apt = false
+      } else {
+        #if apt-get update has not successfully run, we should kick apt_update
+        $_kick_apt = true
       }
     }
-  } else {
-    $_kick_apt = false
+    default: {
+      #catches 'recluctantly', and any other value (which should not occur).
+      #do nothing.
+      $_kick_apt = false
+    }
   }
 
   if $_kick_apt {
@@ -58,11 +51,11 @@ class apt::update {
     $_refresh = true
   }
   exec { 'apt_update':
-    command     => "${apt::params::provider} update",
+    command     => "${::apt::provider} update",
     logoutput   => 'on_failure',
     refreshonly => $_refresh,
-    timeout     => $apt::update_timeout,
-    tries       => $apt::update_tries,
+    timeout     => $::apt::_update['timeout'],
+    tries       => $::apt::_update['tries'],
     try_sleep   => 1
   }
 }
index 5b14ae45ccb3797ed8da0dfa68fa10f819a52c3d..8534aafbd310c282d476ed4c8360f2792243da93 100644 (file)
@@ -35,6 +35,6 @@
     }
   ],
   "dependencies": [
-    {"name":"puppetlabs/stdlib","version_requirement":">= 2.2.1"}
+    {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0"}
   ]
 }
index 1f703c9ce62f02c9059c40f62d667c8b81df81b0..b098e82fc008deab10063ad2f41a3aca22dfc642 100644 (file)
@@ -488,14 +488,14 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
     end
   end
 
-  describe 'keyserver_options =>' do
+  describe 'options =>' do
     context 'debug' do
       it 'works' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id                => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
-          ensure            => 'present',
-          keyserver_options => 'debug',
+          id      => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+          ensure  => 'present',
+          options => 'debug',
         }
         EOS
 
@@ -507,9 +507,9 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       it 'fails on invalid options' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id                => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
-          ensure            => 'present',
-          keyserver_options => 'this is totally bonkers',
+          id      => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+          ensure  => 'present',
+          options => 'this is totally bonkers',
         }
         EOS
 
index 9ace2218093e9f0c562c7aa68b20d2b071efdbcf..c948df2ac22bd2599c9d30cca9659992d69c62f4 100644 (file)
@@ -12,24 +12,28 @@ describe 'apt class' do
     it 'should work with no errors' do
       pp = <<-EOS
       class { 'apt':
-        always_apt_update    => true,
-        disable_keys         => true,
-        purge_sources_list   => true,
-        purge_sources_list_d => true,
-        purge_preferences    => true,
-        purge_preferences_d  => true,
-        update_timeout       => '400',
-        update_tries         => '3',
-        sources              => {
+        update => {
+          'frequency' => 'always',
+          'timeout'   => '400',
+          'tries'     => '3',
+        },
+        purge => {
+          'sources.list'   => true,
+          'sources.list.d' => true,
+          'preferences'    => true,
+          'preferences.d'  => true,
+        },
+        sources => {
           'puppetlabs' => {
-            'ensure'     => present,
-            'location'   => 'http://apt.puppetlabs.com',
-            'repos'      => 'main',
-            'key'        => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
-            'key_server' => 'pgp.mit.edu',
-          }
+            'ensure'   => present,
+            'location' => 'http://apt.puppetlabs.com',
+            'repos'    => 'main',
+            'key'      => {
+              'id'     => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
+              'server' => 'pgp.mit.edu',
+            },
+          },
         },
-        fancy_progress       => true,
       }
       EOS
 
index d3ef34dfa3363c6d6843a53a5631ec926ba5792f..81d5d1bee676ca218070904bbbf8d44eadc5e9cb 100644 (file)
 require 'spec_helper'
-describe 'apt', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+describe 'apt' do
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy'} }
 
   context 'defaults' do
-    it { should contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-      'notify' => 'Exec[apt_update]',
+    it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
+      :ensure  => 'file',
+      :path    => '/etc/apt/sources.list',
+      :owner   => 'root',
+      :group   => 'root',
+      :mode    => '0644',
+      :content => "# Repos managed by puppet.\n",
+      :notify  => 'Exec[apt_update]',
     })}
 
-    it { should contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
-      'ensure'  => 'directory',
-      'path'    => '/etc/apt/sources.list.d',
-      'owner'   => 'root',
-      'group'   => 'root',
-      'purge'   => false,
-      'recurse' => false,
-      'notify'  => 'Exec[apt_update]',
+    it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
+      :ensure  => 'directory',
+      :path    => '/etc/apt/sources.list.d',
+      :owner   => 'root',
+      :group   => 'root',
+      :mode    => '0644',
+      :purge   => true,
+      :recurse => true,
+      :notify  => 'Exec[apt_update]',
     })}
 
-    it { should contain_file('preferences.d').only_with({
-      'ensure'  => 'directory',
-      'path'    => '/etc/apt/preferences.d',
-      'owner'   => 'root',
-      'group'   => 'root',
-      'purge'   => false,
-      'recurse' => false,
+    it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({
+      :ensure  => 'absent',
+      :path    => '/etc/apt/preferences',
+      :owner   => 'root',
+      :group   => 'root',
+      :mode    => '0644',
+      :notify  => 'Exec[apt_update]',
     })}
 
-    it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({
-      'ensure' => 'absent',
-      'path'   => '/etc/apt/apt.conf.d/01proxy',
-      'notify' => 'Exec[apt_update]',
+    it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({
+      :ensure  => 'directory',
+      :path    => '/etc/apt/preferences.d',
+      :owner   => 'root',
+      :group   => 'root',
+      :mode    => '0644',
+      :purge   => true,
+      :recurse => true,
+      :notify  => 'Exec[apt_update]',
     })}
 
     it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
-      should contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
-        'group' => 'root',
-        'mode'  => '0644',
-        'owner' => 'root',
+      is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
+        :group => 'root',
+        :mode  => '0644',
+        :owner => 'root',
       }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
     end
 
-    it { should contain_file('old-proxy-file').that_notifies('Exec[apt_update]').only_with({
-      'ensure' => 'absent',
-      'path'   => '/etc/apt/apt.conf.d/proxy',
-      'notify' => 'Exec[apt_update]',
+    it { is_expected.to contain_exec('apt_update').with({
+      :refreshonly => 'true',
     })}
 
-    it { should contain_exec('apt_update').with({
-      'refreshonly' => 'true',
-    })}
+    it { is_expected.not_to contain_apt__setting('conf-proxy') }
   end
 
+  describe 'proxy=' do
+    context 'host=localhost' do
+      let(:params) { { :proxy => { 'host' => 'localhost'} } }
+      it { is_expected.to contain_apt__setting('conf-proxy').with({
+        :priority => '01',
+      }).with_content(
+        /Acquire::http::proxy "http:\/\/localhost:8080\/";/
+      ).without_content(
+        /Acquire::https::proxy/
+      )}
+    end
+
+    context 'host=localhost and port=8180' do
+      let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
+      it { is_expected.to contain_apt__setting('conf-proxy').with({
+        :priority => '01',
+      }).with_content(
+        /Acquire::http::proxy "http:\/\/localhost:8180\/";/
+      ).without_content(
+        /Acquire::https::proxy/
+      )}
+    end
+
+    context 'host=localhost and https=true' do
+      let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
+      it { is_expected.to contain_apt__setting('conf-proxy').with({
+        :priority => '01',
+      }).with_content(
+        /Acquire::http::proxy "http:\/\/localhost:8080\/";/
+      ).with_content(
+        /Acquire::https::proxy "https:\/\/localhost:8080\/";/
+      )}
+    end
+  end
   context 'lots of non-defaults' do
     let :params do
       {
-        :always_apt_update    => true,
-        :disable_keys         => true,
-        :proxy_host           => 'foo',
-        :proxy_port           => '9876',
-        :purge_sources_list   => true,
-        :purge_sources_list_d => true,
-        :purge_preferences    => true,
-        :purge_preferences_d  => true,
-        :update_timeout       => '1',
-        :update_tries         => '3',
-        :fancy_progress       => true,
+        :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+        :purge  => { 'sources.list' => false, 'sources.list.d' => false,
+                     'preferences' => false, 'preferences.d' => false, },
       }
     end
 
-    it { should contain_file('sources.list').with({
-      'content' => "# Repos managed by puppet.\n"
-    })}
-
-    it { should contain_file('sources.list.d').with({
-      'purge'   => 'true',
-      'recurse' => 'true',
-    })}
-
-    it { should contain_file('apt-preferences').only_with({
-      'ensure' => 'absent',
-      'path'   => '/etc/apt/preferences',
-    })}
-
-    it { should contain_file('preferences.d').with({
-      'purge'   => 'true',
-      'recurse' => 'true',
+    it { is_expected.to contain_file('sources.list').without({
+      :content => "# Repos managed by puppet.\n",
     })}
 
-    it { should contain_file('99progressbar').only_with({
-      'ensure'  => 'present',
-      'content' => /Dpkg::Progress-Fancy "1";/,
-      'path'    => '/etc/apt/apt.conf.d/99progressbar',
+    it { is_expected.to contain_file('sources.list.d').with({
+      :purge   => false,
+      :recurse => false,
     })}
 
-    it { should contain_file('99unauth').only_with({
-      'ensure'  => 'present',
-      'content' => /APT::Get::AllowUnauthenticated 1;/,
-      'path'    => '/etc/apt/apt.conf.d/99unauth',
+    it { is_expected.to contain_file('preferences').with({
+      :ensure => 'file',
     })}
 
-    it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({
-      'ensure'  => 'present',
-      'path'    => '/etc/apt/apt.conf.d/01proxy',
-      'content' => /Acquire::http::Proxy "http:\/\/foo:9876";/,
-      'notify'  => 'Exec[apt_update]',
-      'mode'    => '0644',
-      'owner'   => 'root',
-      'group'   => 'root'
+    it { is_expected.to contain_file('preferences.d').with({
+      :purge   => false,
+      :recurse => false,
     })}
 
-    it { should contain_exec('apt_update').with({
-      'refreshonly' => 'false',
-      'timeout'     => '1',
-      'tries'       => '3',
-    })}
-
-  end
-
-  context 'more non-default' do
-    let :params do
-      {
-        :fancy_progress => false,
-        :disable_keys   => false,
-      }
-    end
-
-    it { should contain_file('99progressbar').only_with({
-      'ensure'  => 'absent',
-      'path'    => '/etc/apt/apt.conf.d/99progressbar',
-    })}
-
-    it { should contain_file('99unauth').only_with({
-      'ensure'  => 'absent',
-      'path'    => '/etc/apt/apt.conf.d/99unauth',
+    it { is_expected.to contain_exec('apt_update').with({
+      :refreshonly => false,
+      :timeout     => 1,
+      :tries       => 3,
     })}
 
   end
@@ -154,98 +140,125 @@ describe 'apt', :type => :class do
         'location'          => 'http://debian.mirror.iweb.ca/debian/',
         'release'           => 'unstable',
         'repos'             => 'main contrib non-free',
-        'required_packages' => 'debian-keyring debian-archive-keyring',
-        'key'               => '150C8614919D8446E01E83AF9AA38DCD55BE302B',
-        'key_server'        => 'subkeys.pgp.net',
+        'key'               => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
         'pin'               => '-10',
-        'include_src'       => true
+        'include'           => {'src' => true,},
       },
       'puppetlabs' => {
         'location'   => 'http://apt.puppetlabs.com',
         'repos'      => 'main',
-        'key'        => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
-        'key_server' => 'pgp.mit.edu',
+        'key'        => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' },
       }
     } } }
 
     it {
-      should contain_file('debian_unstable.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
+      is_expected.to contain_apt__setting('list-debian_unstable').with({
+        :ensure => 'present',
       })
     }
 
-    it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-    it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
 
     it {
-      should contain_file('puppetlabs.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
+      is_expected.to contain_apt__setting('list-puppetlabs').with({
+        :ensure => 'present',
       })
     }
 
-    it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
-    it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
+  end
+
+  context 'with keys defined on valid osfamily' do
+    let :facts do
+      { :osfamily        => 'Debian',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'Debian',
+      }
+    end
+    let(:params) { { :keys => {
+      '55BE302B' => {
+        'server' => 'subkeys.pgp.net',
+      },
+      '4BD6EC30' => {
+        'server' => 'pgp.mit.edu',
+      }
+    } } }
+
+    it { is_expected.to contain_apt__key('55BE302B').with({
+        :server => 'subkeys.pgp.net',
+    })}
+
+    it { is_expected.to contain_apt__key('4BD6EC30').with({
+        :server => 'pgp.mit.edu',
+    })}
+  end
+
+  context 'with ppas defined on valid osfamily' do
+    let :facts do
+      { :osfamily        => 'Debian',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'ubuntu',
+      }
+    end
+    let(:params) { { :ppas => {
+      'ppa:drizzle-developers/ppa' => {},
+      'ppa:nginx/stable' => {},
+    } } }
+
+    it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
+    it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
+  end
+
+  context 'with settings defined on valid osfamily' do
+    let :facts do
+      { :osfamily        => 'Debian',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'Debian',
+      }
+    end
+    let(:params) { { :settings => {
+      'conf-banana' => { 'content' => 'banana' },
+      'pref-banana' => { 'content' => 'banana' },
+    } } }
+
+    it { is_expected.to contain_apt__setting('conf-banana')}
+    it { is_expected.to contain_apt__setting('pref-banana')}
   end
 
   describe 'failing tests' do
-    context 'bad purge_sources_list' do
-      let :params do
-        {
-          'purge_sources_list' => 'foo'
-        }
-      end
+    context "purge['sources.list']=>'banana'" do
+      let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error)
       end
     end
 
-    context 'bad purge_sources_list_d' do
-      let :params do
-        {
-          'purge_sources_list_d' => 'foo'
-        }
-      end
+    context "purge['sources.list.d']=>'banana'" do
+      let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } }
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error)
       end
     end
 
-    context 'bad purge_preferences' do
-      let :params do
-        {
-          'purge_preferences' => 'foo'
-        }
-      end
+    context "purge['preferences']=>'banana'" do
+      let(:params) { { :purge => { 'preferences' => 'banana' }, } }
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error)
       end
     end
 
-    context 'bad purge_preferences_d' do
-      let :params do
-        {
-          'purge_preferences_d' => 'foo'
-        }
-      end
+    context "purge['preferences.d']=>'banana'" do
+      let(:params) { { :purge => { 'preferences.d' => 'banana' }, } }
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error)
       end
     end
@@ -257,7 +270,7 @@ describe 'apt', :type => :class do
 
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
       end
     end
index d70efd37d1edff19f64e9a242168422bd736b1e2..8fba4a0c98860e57bb2d7b948c8436cd59aab616 100644 (file)
 require 'spec_helper'
 
 describe 'apt::update', :type => :class do
-  context 'when apt::always_apt_update is true' do
-    #This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior.
-    let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-    let (:pre_condition) { "class{'::apt': always_apt_update => true}" }
-    it 'should trigger an apt-get update run' do
-      #set the apt_update exec's refreshonly attribute to false
-      should contain_exec('apt_update').with({'refreshonly' => false })
-    end
-    ['always','daily','weekly','reluctantly'].each do |update_frequency|
-      context "when apt::apt_update_frequency has the value of #{update_frequency}" do
-        { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
-          context "and $::apt_update_last_success indicates #{desc}" do
-            let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } }
-            let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" }
-            it 'should trigger an apt-get update run' do
-              # set the apt_update exec's refreshonly attribute to false
-              should contain_exec('apt_update').with({'refreshonly' => false})
-            end
-          end
-          context 'when $::apt_update_last_success is nil' do
-            let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-            let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" }
-            it 'should trigger an apt-get update run' do
-              #set the apt_update exec\'s refreshonly attribute to false
-              should contain_exec('apt_update').with({'refreshonly' => false})
-            end
-          end
+  context "and apt::update['frequency']='always'" do
+    { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+      context "and $::apt_update_last_success indicates #{desc}" do
+        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } }
+        let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" }
+        it 'should trigger an apt-get update run' do
+          #set the apt_update exec's refreshonly attribute to false
+          is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
         end
       end
     end
+    context 'when $::apt_update_last_success is nil' do
+      let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
+      let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
+      it 'should trigger an apt-get update run' do
+        #set the apt_update exec\'s refreshonly attribute to false
+        is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
+      end
+    end
   end
-
-  context 'when apt::always_apt_update is false' do
-    context "and apt::apt_update_frequency has the value of always" do
-      { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
-        context "and $::apt_update_last_success indicates #{desc}" do
-          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } }
-          let (:pre_condition) { "class{'::apt': always_apt_update => false, apt_update_frequency => 'always' }" }
-          it 'should trigger an apt-get update run' do
-            #set the apt_update exec's refreshonly attribute to false
-            should contain_exec('apt_update').with({'refreshonly' => false})
-          end
+  context "and apt::update['frequency']='reluctantly'" do
+    {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+      context "and $::apt_update_last_success indicates #{desc}" do
+        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} }
+        let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
+        it 'should not trigger an apt-get update run' do
+          #don't change the apt_update exec's refreshonly attribute. (it should be true)
+          is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
         end
       end
-      context 'when $::apt_update_last_success is nil' do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-        let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'always' }" }
-        it 'should trigger an apt-get update run' do
-          #set the apt_update exec\'s refreshonly attribute to false
-          should 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' } }
+      let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
+      it 'should not trigger an apt-get update run' do
+        #don't change the apt_update exec's refreshonly attribute. (it should be true)
+        is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
       end
     end
-    context "and apt::apt_update_frequency has the value of 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|
+  end
+  ['daily','weekly'].each do |update_frequency|
+    context "and apt::update['frequency'] has the value of #{update_frequency}" do
+      { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
         context "and $::apt_update_last_success indicates #{desc}" do
-          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval} }
-          let (:pre_condition) { "class{ '::apt': always_apt_update => false, 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)
-            should contain_exec('apt_update').with({'refreshonly' => true})
+          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } }
+          let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
+          it 'should trigger an apt-get update run' do
+            #set the apt_update exec\'s refreshonly attribute to false
+            is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
           end
         end
       end
-      context 'when $::apt_update_last_success is nil' do
-        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-        let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" }
+      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 } }
+        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)
-          should contain_exec('apt_update').with({'refreshonly' => true})
+          #don't change the apt_update exec\'s refreshonly attribute. (it should be true)
+          is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
         end
       end
-    end
-    ['daily','weekly'].each do |update_frequency|
-      context "and apt::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 } }
-            let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" }
-            it 'should trigger an apt-get update run' do
-              #set the apt_update exec\'s refreshonly attribute to false
-              should contain_exec('apt_update').with({'refreshonly' => false})
-            end
-          end
-        end
-        context 'when the $::apt_update_last_success fact has a recent value' do
-          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => Time.now.to_i } }
-          let (:pre_condition) { "class{ '::apt': always_apt_update => false, 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)
-            should contain_exec('apt_update').with({'refreshonly' => true})
-          end
-        end
-        context 'when $::apt_update_last_success is nil' do
-          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-          let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" }
-          it 'should trigger an apt-get update run' do
-            #set the apt_update exec\'s refreshonly attribute to false
-            should contain_exec('apt_update').with({'refreshonly' => false})
-          end
+      context 'when $::apt_update_last_success is nil' do
+        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } }
+        let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
+        it 'should trigger an apt-get update run' do
+          #set the apt_update exec\'s refreshonly attribute to false
+          is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
         end
       end
     end
diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb
deleted file mode 100644 (file)
index 721a4a6..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-require 'spec_helper'
-describe 'apt::backports', :type => :class do
-
-  describe 'when asigning a custom priority to backports' do
-    let :facts do
-      {
-        'lsbdistcodename' => 'Karmic',
-        'lsbdistid'       => 'Ubuntu',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    context 'integer priority' do
-      let :params do { :pin_priority => 500 } end
-
-      it { should contain_apt__source('backports').with({
-          'location'   => 'http://old-releases.ubuntu.com/ubuntu',
-          'release'    => 'karmic-backports',
-          'repos'      => 'main universe multiverse restricted',
-          'key'        => '630239CC130E1A7FD81A27B140976EAF437D05B5',
-          'key_server' => 'pgp.mit.edu',
-        })
-      }
-
-      it { should contain_apt__pin('backports').with({
-          'release'  => 'karmic-backports',
-          'priority' => 500,
-        })
-      }
-    end
-
-    context 'invalid priority' do
-      let :params do { :pin_priority => 'banana' } end
-      it 'should fail' do
-        expect { subject }.to raise_error(/must be an integer/)
-      end
-    end
-  end
-
-  describe 'when turning on backports for ubuntu karmic' do
-
-    let :facts do
-      {
-        'lsbdistcodename' => 'Karmic',
-        'lsbdistid'       => 'Ubuntu',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    it { should contain_apt__source('backports').with({
-        'location'   => 'http://old-releases.ubuntu.com/ubuntu',
-        'release'    => 'karmic-backports',
-        'repos'      => 'main universe multiverse restricted',
-        'key'        => '630239CC130E1A7FD81A27B140976EAF437D05B5',
-        'key_server' => 'pgp.mit.edu',
-      })
-    }
-
-    it { should contain_apt__pin('backports').with({
-        'release'  => 'karmic-backports',
-        'priority' => 200,
-      })
-    }
-  end
-
-  describe "when turning on backports for debian squeeze" do
-
-    let :facts do
-      {
-        'lsbdistcodename' => 'Squeeze',
-        'lsbdistid'       => 'Debian',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    it { should contain_apt__source('backports').with({
-        'location'   => 'http://backports.debian.org/debian-backports',
-        'release'    => 'squeeze-backports',
-        'repos'      => 'main contrib non-free',
-        'key'        => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-        'key_server' => 'pgp.mit.edu',
-      })
-    }
-
-    it { should contain_apt__pin('backports').with({
-        'release'  => 'squeeze-backports',
-        'priority' => 200,
-      })
-    }
-  end
-
-  describe "when turning on backports for linux mint debian edition" do
-
-    let :facts do
-      {
-        'lsbdistcodename' => 'debian',
-        'lsbdistid'       => 'LinuxMint',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    it { should contain_apt__source('backports').with({
-        'location'   => 'http://ftp.debian.org/debian/',
-        'release'    => 'wheezy-backports',
-        'repos'      => 'main contrib non-free',
-        'key'        => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-        'key_server' => 'pgp.mit.edu',
-      })
-    }
-
-    it { should contain_apt__pin('backports').with({
-        'release'  => 'wheezy-backports',
-        'priority' => 200,
-      })
-    }
-  end
-
-  describe "when turning on backports for linux mint 17 (ubuntu-based)" do
-
-    let :facts do
-      {
-        'lsbdistcodename' => 'qiana',
-        'lsbdistid'       => 'LinuxMint',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    it { should contain_apt__source('backports').with({
-        'location'   => 'http://us.archive.ubuntu.com/ubuntu',
-        'release'    => 'trusty-backports',
-        'repos'      => 'main universe multiverse restricted',
-        'key'        => '630239CC130E1A7FD81A27B140976EAF437D05B5',
-        'key_server' => 'pgp.mit.edu',
-      })
-    }
-
-    it { should contain_apt__pin('backports').with({
-        'release'  => 'trusty-backports',
-        'priority' => 200,
-      })
-    }
-  end
-
-  describe "when turning on backports for debian squeeze but using your own mirror" do
-
-    let :facts do
-      {
-        'lsbdistcodename' => 'Squeeze',
-        'lsbdistid'       => 'Debian',
-        'osfamily'        => 'Debian'
-      }
-    end
-
-    let :location do
-      'http://mirrors.example.com/debian-backports'
-    end
-
-    let :params do
-      { 'location' => location }
-    end
-
-    it { should contain_apt__source('backports').with({
-        'location'   => location,
-        'release'    => 'squeeze-backports',
-        'repos'      => 'main contrib non-free',
-        'key'        => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
-        'key_server' => 'pgp.mit.edu',
-      })
-    }
-
-    it { should contain_apt__pin('backports').with({
-        'release'  => 'squeeze-backports',
-        'priority' => 200,
-      })
-    }
-  end
-end
diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb
deleted file mode 100644 (file)
index a2e35f5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'spec_helper'
-describe 'apt::debian::testing', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-  it {
-    should contain_apt__source("debian_testing").with({
-      "location"            => "http://debian.mirror.iweb.ca/debian/",
-      "release"             => "testing",
-      "repos"               => "main contrib non-free",
-      "required_packages"   => "debian-keyring debian-archive-keyring",
-      "key"                 => "A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553",
-      "key_server"          => "subkeys.pgp.net",
-      "pin"                 => "-10"
-    })
-  }
-end
diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb
deleted file mode 100644 (file)
index 14d8650..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'spec_helper'
-describe 'apt::debian::unstable', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-  it {
-    should contain_apt__source("debian_unstable").with({
-      "location"          => "http://debian.mirror.iweb.ca/debian/",
-      "release"           => "unstable",
-      "repos"             => "main contrib non-free",
-      "required_packages" => "debian-keyring debian-archive-keyring",
-      "key"               => "A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553",
-      "key_server"        => "subkeys.pgp.net",
-      "pin"               => "-10"
-    })
-  }
-end
index d85e849d5ae31a370ccce001f274f449608f32f9..f8ca89f2a33f9ec04e73dc459dfaa85e204ba194 100644 (file)
@@ -1,37 +1,37 @@
 require 'spec_helper'
 describe 'apt::params', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
   let (:title) { 'my_package' }
 
-  it { should contain_apt__params }
+  it { is_expected.to contain_apt__params }
 
   # There are 4 resources in this class currently
   # there should not be any more resources because it is a params class
   # The resources are class[apt::params], class[main], class[settings], stage[main]
   it "Should not contain any resources" do
-    subject.resources.size.should == 4
+    expect(subject.resources.size).to eq(4)
   end
 
   describe "With unknown lsbdistid" do
 
-    let(:facts) { { :lsbdistid => 'CentOS' } }
+    let(:facts) { { :lsbdistid => 'CentOS', :osfamily => 'Debian' } }
     let (:title) { 'my_package' }
 
     it do
       expect {
-       should compile
+       is_expected.to compile
       }.to raise_error(Puppet::Error, /Unsupported lsbdistid/)
     end
 
   end
 
   describe "With lsb-release not installed" do
-    let(:facts) { { :lsbdistid => '' } }
+    let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } }
     let (:title) { 'my_package' }
 
     it do
       expect {
-        should compile
+        is_expected.to compile
       }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/)
     end
   end
diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb
deleted file mode 100644 (file)
index f8c6512..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'spec_helper'
-describe 'apt::release', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian' } }
-  let (:title) { 'my_package' }
-
-  let :param_set do
-    { :release_id => 'precise' }
-  end
-
-  let (:params) { param_set }
-
-  it { should contain_class("apt::params") }
-
-  it {
-    should contain_file("/etc/apt/apt.conf.d/01release").with({
-      "mode"    => "0644",
-      "owner"   => "root",
-      "group"   => "root",
-      "content" => /APT::Default-Release "#{param_set[:release_id]}";/
-    })
-  }
-end
-
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
deleted file mode 100644 (file)
index 0a02755..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-require 'spec_helper'
-describe 'apt::unattended_upgrades', :type => :class do
-  let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
-  let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
-  let(:facts) { { :lsbdistid => 'Debian' } }
-
-  it { should contain_package("unattended-upgrades") }
-
-  it {
-    should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({
-      "owner"   => "root",
-      "group"   => "root",
-      "mode"    => "0644",
-      "require" => "Package[unattended-upgrades]",
-    })
-  }
-
-  it {
-    should create_file("/etc/apt/apt.conf.d/10periodic").with({
-      "owner"   => "root",
-      "group"   => "root",
-      "mode"    => "0644",
-      "require" => "Package[unattended-upgrades]",
-    })
-  }
-
-  describe 'failing' do
-    let :facts do
-      {
-        'lsbdistid'       => 'debian',
-        'lsbdistcodename' => 'squeeze',
-      }
-    end
-    context 'bad auto_fix' do
-      let :params do
-        {
-          'auto_fix' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad minimal_steps' do
-      let :params do
-        {
-          'minimal_steps' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad install_on_shutdown' do
-      let :params do
-        {
-          'install_on_shutdown' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad mail_only_on_error' do
-      let :params do
-        {
-          'mail_only_on_error' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad remove_unused' do
-      let :params do
-        {
-          'remove_unused' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad auto_reboot' do
-      let :params do
-        {
-          'auto_reboot' => 'foo',
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad origins' do
-      let :params do
-        {
-          'origins' => 'foo'
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-
-    context 'bad randomsleep' do
-      let :params do
-        {
-          'randomsleep' => '4ever'
-        }
-      end
-      it { expect { should raise_error(Puppet::Error) } }
-    end
-  end
-
-  context 'defaults' do
-    let :facts do
-      {
-        'lsbdistid'       => 'debian',
-        'lsbdistcodename' => 'squeeze',
-      }
-    end
-
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id} oldstable";\n\t"\${distro_id} \${distro_codename}-security";\n\t"\${distro_id} \${distro_codename}-lts";\n\};} }
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "false";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "false";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "false";}}
-
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "3";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}}
-    it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}}
-  end
-
-  context 'wheezy' do
-    let :facts do
-      {
-        'lsbdistid'       => 'debian',
-        'lsbdistcodename' => 'wheezy',
-      }
-    end
-
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"origin=Debian,archive=stable,label=Debian-Security";\n\t"origin=Debian,archive=oldstable,label=Debian-Security";\n\};} }
-  end
-
-  context 'anything but defaults' do
-    let :facts do
-      {
-        'lsbdistid'       => 'debian',
-        'lsbdistcodename' => 'wheezy',
-      }
-    end
-
-    let :params do
-      {
-        'legacy_origin'       => true,
-        'enable'              => '0',
-        'backup_interval'     => '3',
-        'backup_level'        => '1',
-        'max_age'             => '7',
-        'min_age'             => '1',
-        'max_size'            => '100',
-        'update'              => '0',
-        'download'            => '0',
-        'download_delta'      => '1',
-        'upgrade'             => '0',
-        'autoclean'           => '0',
-        'verbose'             => '1',
-        'origins'             => ['bananas'],
-        'blacklist'           => ['foo', 'bar'],
-        'auto_fix'            => false,
-        'minimal_steps'       => true,
-        'install_on_shutdown' => true,
-        'mail_to'             => 'root@localhost',
-        'mail_only_on_error'  => true,
-        'remove_unused'       => false,
-        'auto_reboot'         => true,
-        'dl_limit'            => '70',
-        'randomsleep'         => '1799',
-      }
-    end
-
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"bananas";\n\};} }
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} }
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Mail "root@localhost";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MailOnlyOnError "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "false";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "true";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Acquire::http::Dl-Limit "70";}}
-
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "3";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "7";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "100";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}}
-    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}}
-
-  end
-end
diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb
deleted file mode 100644 (file)
index 41152d5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'spec_helper'
-describe 'apt::builddep', :type => :define do
-
-  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-  let(:title) { 'my_package' }
-
-  describe "defaults" do
-    it { should contain_exec("apt-builddep-my_package").that_requires('Exec[apt_update]').with({
-        'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package",
-        'logoutput' => 'on_failure'
-      })
-    }
-    it { should contain_anchor("apt::builddep::my_package").with({
-        'require' => 'Class[Apt::Update]',
-      })
-    }
-  end
-
-end
index 2c1752f074cb301741edc771a4ba3420bae950b0..a7db4e61e3f54ffed20db74884cf93ef63304525 100644 (file)
@@ -1,6 +1,9 @@
 require 'spec_helper'
 describe 'apt::conf', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let :pre_condition do
+    'class { "apt": }'
+  end
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
   let :title do
     'norecommends'
   end
@@ -17,7 +20,7 @@ describe 'apt::conf', :type => :define do
       "/etc/apt/apt.conf.d/00norecommends"
     end
 
-    it { should contain_file(filename).with({
+    it { is_expected.to contain_file(filename).with({
           'ensure'    => 'present',
           'content'   => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/,
           'owner'     => 'root',
@@ -40,7 +43,7 @@ describe 'apt::conf', :type => :define do
       "/etc/apt/apt.conf.d/00norecommends"
     end
 
-    it { should contain_file(filename).with({
+    it { is_expected.to contain_file(filename).with({
         'ensure'    => 'absent',
         'content'   => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/,
         'owner'     => 'root',
diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb
deleted file mode 100644 (file)
index c32c438..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-require 'spec_helper'
-describe 'apt::force', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
-  let :pre_condition do
-    'include apt::params'
-  end
-
-  let :title do
-    'my_package'
-  end
-
-  let :default_params do
-    {
-      :release     => false,
-      :version     => false,
-      :cfg_files   => 'none',
-      :cfg_missing => false,
-    }
-  end
-
-  describe "when using default parameters" do
-    it { should contain_exec("/usr/bin/apt-get -y    install #{title}").with(
-      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
-      :logoutput => 'on_failure',
-      :timeout   => '300'
-    ) }
-  end
-
-  describe "when specifying release parameter" do
-    let :params do
-      default_params.merge(:release => 'testing')
-    end
-    it { should contain_exec("/usr/bin/apt-get -y   -t #{params[:release]} install #{title}").with(
-      :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
-    ) }
-  end
-
-  describe "when specifying version parameter" do
-    let :params do
-      default_params.merge(:version => '1')
-    end
-    it { should contain_exec("/usr/bin/apt-get -y    install #{title}=#{params[:version]}").with(
-      :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'"
-    ) }
-  end
-
-  describe "when specifying cfg_files parameter" do
-    let :params do
-      default_params.merge(:cfg_files => 'unchanged')
-    end
-    it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef"   install my_package').with(
-      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
-    ) }
-  end
-
-  describe "when specifying cfg_missing parameter" do
-    let :params do
-      default_params.merge(:cfg_missing => true)
-    end
-    it { should contain_exec('/usr/bin/apt-get -y  -o Dpkg::Options::="--force-confmiss"  install my_package').with(
-      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
-    ) }
-  end
-
-  describe "when specifying cfg_files and cfg_missing parameter" do
-   let :params do
-     default_params.merge(
-       :cfg_files   => 'unchanged',
-       :cfg_missing => true
-     )
-   end
-   it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss"  install my_package').with(
-     :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
-   ) }
-  end
-
-  describe "when specifying release and version parameters" do
-    let :params do
-      default_params.merge(
-        :release => 'testing',
-        :version => '1'
-      )
-    end
-    it { should contain_exec("/usr/bin/apt-get -y   -t #{params[:release]} install #{title}=1").with(
-      :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
-    ) }
-  end
-
-  describe "when specifying release, version, cfg_files and cfg_missing parameters" do
-   let :params do
-     default_params.merge(
-       :release     => 'testing',
-       :version     => '1',
-       :cfg_files   => 'unchanged',
-       :cfg_missing => true
-     )
-   end
-   it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" -t testing install my_package=1').with(
-     :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
-   ) }
-  end
-end
diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb
deleted file mode 100644 (file)
index 60b991f..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-require 'spec_helper'
-describe 'apt::hold' do
-  let :facts do {
-    :osfamily   => 'Debian',
-    :lsbdistid  => 'Debian',
-    :lsbrelease => 'wheezy',
-  } end
-
-  let :title do
-    'vim'
-  end
-
-  let :default_params do {
-    :version => '1.1.1',
-  } end
-
-  describe 'default params' do
-    let :params do default_params end
-
-    it 'creates an apt preferences file' do
-      should contain_apt__pin("hold_#{title}").with({
-        :ensure   => 'present',
-        :packages => title,
-        :version  => params[:version],
-        :priority => 1001,
-      })
-    end
-  end
-
-  describe 'ensure => absent' do
-    let :params do default_params.merge({:ensure => 'absent',}) end
-
-    it 'creates an apt preferences file' do
-
-      should contain_apt__pin("hold_#{title}").with({
-        :ensure   => params[:ensure],
-      })
-    end
-  end
-
-  describe 'priority => 990' do
-    let :params do default_params.merge({:priority => 990,}) end
-
-    it 'creates an apt preferences file' do
-      should contain_apt__pin("hold_#{title}").with({
-        :ensure   => 'present',
-        :packages => title,
-        :version  => params[:version],
-        :priority => params[:priority],
-      })
-    end
-  end
-
-  describe 'package => foo' do
-    let :params do default_params.merge({:package => 'foo'}) end
-
-    it 'creates an apt preferences file' do
-      should contain_apt__pin("hold_foo").with({
-        :ensure   => 'present',
-        :packages => 'foo',
-        :version  => params[:version],
-        :priority => 1001,
-      })
-    end
-  end
-
-
-  describe 'validation' do
-    context 'version => {}' do
-      let :params do { :version => {}, } end
-      it 'should fail' do
-        expect { subject }.to raise_error(/is not a string/)
-      end
-    end
-
-    context 'ensure => bananana' do
-      let :params do default_params.merge({:ensure => 'bananana',}) end
-      it 'should fail' do
-        expect { subject }.to raise_error(/does not match/)
-      end
-    end
-
-    context 'package => []' do
-      let :params do default_params.merge({:package => [],}) end
-      it 'should fail' do
-        expect { subject }.to raise_error(/is not a string/)
-      end
-    end
-
-    context 'priority => bananana' do
-      let :params do default_params.merge({:priority => 'bananana',}) end
-      it 'should fail' do
-        expect { subject }.to raise_error(/must be an integer/)
-      end
-    end
-  end
-end
index 7ac1d2813089a8092d861acf570a1c3c1237784f..b9bcea845a7916e67dabd750ba1658b76eb9743b 100644 (file)
@@ -1,7 +1,12 @@
 require 'spec_helper'
 
-describe 'apt::key', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+describe 'apt::key' do
+  let :pre_condition do
+    'class { "apt": }'
+  end
+
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
+
   GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
 
   let :title do
@@ -11,17 +16,17 @@ describe 'apt::key', :type => :define do
   describe 'normal operation' do
     describe 'default options' do
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
+        is_expected.to contain_apt_key(title).with({
+          :id      => title,
+          :ensure  => 'present',
+          :source  => nil,
+          :server  => 'keyserver.ubuntu.com',
+          :content => nil,
+          :options => nil,
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+        is_expected.to contain_anchor("apt_key #{title} present")
       end
     end
 
@@ -31,21 +36,21 @@ describe 'apt::key', :type => :define do
       end
 
       let :params do {
-        :key => GPG_KEY_ID,
+        :id => GPG_KEY_ID,
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => GPG_KEY_ID,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
+        is_expected.to contain_apt_key(title).with({
+          :id      => GPG_KEY_ID,
+          :ensure  => 'present',
+          :source  => nil,
+          :server  => 'keyserver.ubuntu.com',
+          :content => nil,
+          :options => nil,
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{GPG_KEY_ID} present")
+        is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
       end
     end
 
@@ -55,49 +60,49 @@ describe 'apt::key', :type => :define do
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'absent',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
+        is_expected.to contain_apt_key(title).with({
+          :id        => title,
+          :ensure    => 'absent',
+          :source    => nil,
+          :server    => 'keyserver.ubuntu.com',
+          :content   => nil,
+          :keyserver => nil,
         })
       end
       it 'contains the apt_key absent anchor' do
-        should contain_anchor("apt_key #{title} absent")
+        is_expected.to contain_anchor("apt_key #{title} absent")
       end
     end
 
     describe 'set a bunch of things!' do
       let :params do {
-        :key_content => 'GPG key content',
-        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-        :key_server => 'pgp.mit.edu',
-        :key_options => 'debug',
+        :content => 'GPG key content',
+        :source  => 'http://apt.puppetlabs.com/pubkey.gpg',
+        :server  => 'pgp.mit.edu',
+        :options => 'debug',
       } end
 
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => 'http://apt.puppetlabs.com/pubkey.gpg',
-          :server            => 'pgp.mit.edu',
-          :content           => params[:key_content],
-          :keyserver_options => 'debug',
+        is_expected.to contain_apt_key(title).with({
+          :id      => title,
+          :ensure  => 'present',
+          :source  => 'http://apt.puppetlabs.com/pubkey.gpg',
+          :server  => 'pgp.mit.edu',
+          :content => params[:content],
+          :options => 'debug',
         })
       end
       it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+        is_expected.to contain_anchor("apt_key #{title} present")
       end
     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
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'p-gp.m-it.edu',
         })
@@ -107,11 +112,11 @@ describe 'apt::key', :type => :define do
     context "url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu',
+          :server => 'hkp://pgp.mit.edu',
         }
       end
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'hkp://pgp.mit.edu',
         })
@@ -120,11 +125,11 @@ describe 'apt::key', :type => :define do
     context "url with port number" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:80',
+          :server => 'hkp://pgp.mit.edu:80',
         }
       end
       it 'contains the apt_key' do
-        should contain_apt_key(title).with({
+        is_expected.to contain_apt_key(title).with({
           :id        => title,
           :server => 'hkp://pgp.mit.edu:80',
         })
@@ -135,7 +140,7 @@ describe 'apt::key', :type => :define do
   describe 'validation' do
     context "domain begin with dash" do
       let(:params) do{
-        :key_server => '-pgp.mit.edu',
+        :server => '-pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject } .to raise_error(/does not match/)
@@ -144,7 +149,7 @@ describe 'apt::key', :type => :define do
 
     context "domain begin with dot" do
       let(:params) do{
-        :key_server => '.pgp.mit.edu',
+        :server => '.pgp.mit.edu',
       } end
       it 'fails' do
         expect { subject } .to raise_error(/does not match/)
@@ -153,7 +158,7 @@ describe 'apt::key', :type => :define do
 
     context "domain end with dot" do
       let(:params) do{
-        :key_server => "pgp.mit.edu.",
+        :server => "pgp.mit.edu.",
       } end
       it 'fails' do
         expect { subject } .to raise_error(/does not match/)
@@ -162,7 +167,7 @@ describe 'apt::key', :type => :define do
     context "exceed character url" do
       let :params do
         {
-          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+          :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
         }
       end
       it 'fails' do
@@ -172,7 +177,7 @@ describe 'apt::key', :type => :define do
     context "incorrect port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:8008080'
+          :server => 'hkp://pgp.mit.edu:8008080'
         }
       end
       it 'fails' do
@@ -182,7 +187,7 @@ describe 'apt::key', :type => :define do
     context "incorrect protocol for  url" do
       let :params do
         {
-          :key_server => 'abc://pgp.mit.edu:80'
+          :server => 'abc://pgp.mit.edu:80'
         }
       end
       it 'fails' do
@@ -192,7 +197,7 @@ describe 'apt::key', :type => :define do
     context "missing port number url" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu:'
+          :server => 'hkp://pgp.mit.edu:'
         }
       end
       it 'fails' do
@@ -202,7 +207,7 @@ describe 'apt::key', :type => :define do
     context "url ending with a dot" do
       let :params do
         {
-          :key_server => 'hkp://pgp.mit.edu.'
+          :server => 'hkp://pgp.mit.edu.'
         }
       end
       it 'fails' do
@@ -211,7 +216,7 @@ describe 'apt::key', :type => :define do
     end
     context "url begin with a dash" do
       let(:params) do{
-        :key_server => "hkp://-pgp.mit.edu",
+        :server => "hkp://-pgp.mit.edu",
       } end
       it 'fails' do
         expect { subject }.to raise_error(/does not match/)
@@ -228,7 +233,7 @@ describe 'apt::key', :type => :define do
 
     context 'invalid source' do
       let :params do {
-        :key_source => 'afp://puppetlabs.com/key.gpg',
+        :source => 'afp://puppetlabs.com/key.gpg',
       } end
       it 'fails' do
         expect { subject }.to raise_error(/does not match/)
@@ -237,7 +242,7 @@ describe 'apt::key', :type => :define do
 
     context 'invalid content' do
       let :params do {
-        :key_content => [],
+        :content => [],
       } end
       it 'fails' do
         expect { subject }.to raise_error(/is not a string/)
@@ -246,16 +251,16 @@ describe 'apt::key', :type => :define do
 
     context 'invalid server' do
       let :params do {
-        :key_server => 'two bottles of rum',
+        :server => 'two bottles of rum',
       } end
       it 'fails' do
         expect { subject }.to raise_error(/does not match/)
       end
     end
 
-    context 'invalid keyserver_options' do
+    context 'invalid options' do
       let :params do {
-        :key_options => {},
+        :options => {},
       } end
       it 'fails' do
         expect { subject }.to raise_error(/is not a string/)
@@ -276,36 +281,38 @@ describe 'apt::key', :type => :define do
     describe 'duplication' do
       context 'two apt::key resources for same key, different titles' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => '#{title}', }"
+          "class { 'apt': }
+          apt::key { 'duplicate': id => '#{title}', }"
         end
 
         it 'contains two apt::key resources' do
-          should contain_apt__key('duplicate').with({
-            :key    => title,
+          is_expected.to contain_apt__key('duplicate').with({
+            :id     => title,
             :ensure => 'present',
           })
-          should contain_apt__key(title).with({
-            :key    => title,
+          is_expected.to contain_apt__key(title).with({
+            :id     => title,
             :ensure => 'present',
           })
         end
 
         it 'contains only a single apt_key' do
-          should contain_apt_key('duplicate').with({
-            :id                => title,
-            :ensure            => 'present',
-            :source            => nil,
-            :server            => nil,
-            :content           => nil,
-            :keyserver_options => nil,
+          is_expected.to contain_apt_key('duplicate').with({
+            :id      => title,
+            :ensure  => 'present',
+            :source  => nil,
+            :server  => 'keyserver.ubuntu.com',
+            :content => nil,
+            :options => nil,
           })
-          should_not contain_apt_key(title)
+          is_expected.not_to contain_apt_key(title)
         end
       end
 
       context 'two apt::key resources, different ensure' do
         let :pre_condition do
-          "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+          "class { 'apt': }
+          apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
         end
         it 'informs the user of the impossibility' do
           expect { subject }.to raise_error(/already ensured as absent/)
index 23ebd59b32d77d08c28108a3c9ff79c64ead7175..a11c3b5c253156dcae5b2866286932918f7c99ef 100644 (file)
@@ -1,18 +1,14 @@
 require 'spec_helper'
 describe 'apt::pin', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let :pre_condition do
+    'class { "apt": }'
+  end
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
   let(:title) { 'my_pin' }
 
   context 'defaults' do
-    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_file("my_pin.pref").with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/preferences.d/my_pin.pref',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    })
-    }
+    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
@@ -22,15 +18,8 @@ describe 'apt::pin', :type => :define do
         'version'  => '1',
       }
     end
-    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_file("my_pin.pref").with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/preferences.d/my_pin.pref',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    })
-    }
+    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
@@ -40,15 +29,8 @@ describe 'apt::pin', :type => :define do
         'origin'   => 'test',
       }
     end
-    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
-    it { is_expected.to contain_file("my_pin.pref").with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/preferences.d/my_pin.pref',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    })
-    }
+    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
@@ -65,13 +47,9 @@ describe 'apt::pin', :type => :define do
         'priority'        => 10,
       }
     end
-    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
-    it { is_expected.to contain_file("my_pin.pref").with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/preferences.d/99-my_pin.pref',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
+    it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
+    it { is_expected.to contain_apt__setting("pref-my_pin").with({
+      'priority'     => 99,
     })
     }
   end
@@ -82,7 +60,7 @@ describe 'apt::pin', :type => :define do
         'ensure' => 'absent'
       }
     end
-    it { is_expected.to contain_file("my_pin.pref").with({
+    it { is_expected.to contain_apt__setting("pref-my_pin").with({
       'ensure' => 'absent',
     })
     }
@@ -90,7 +68,7 @@ describe 'apt::pin', :type => :define do
 
   context 'bad characters' do
     let(:title) { 'such  bad && wow!' }
-    it { is_expected.to contain_file("such__bad____wow_.pref") }
+    it { is_expected.to contain_apt__setting("pref-such__bad____wow_") }
   end
 
   describe 'validation' do
@@ -102,7 +80,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /Only integers are allowed/)
       end
     end
@@ -115,7 +93,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
       end
     end
@@ -129,7 +107,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
       end
     end
@@ -144,7 +122,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
       end
     end
@@ -159,7 +137,7 @@ describe 'apt::pin', :type => :define do
       end
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
       end
     end
index 866d323004fe96ff8129d4fbc1f6f804f3acf101..7903e470377410d2df8320148c066970bb331445 100644 (file)
@@ -1,10 +1,10 @@
 require 'spec_helper'
-describe 'apt::ppa', :type => :define do
+describe 'apt::ppa' do
+  let :pre_condition do
+    'class { "apt": }'
+  end
 
   describe 'defaults' do
-    let :pre_condition do
-      'class { "apt": }'
-    end
     let :facts do
       {
         :lsbdistrelease  => '11.04',
@@ -16,20 +16,21 @@ describe 'apt::ppa', :type => :define do
     end
 
     let(:title) { 'ppa:needs/such.substitution/wow' }
-    it { is_expected.to contain_package('python-software-properties') }
+    it { is_expected.to_not contain_package('python-software-properties') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
-      'environment' => [],
-      'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => [],
+      :command     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
+  end
 
-    it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
-      'ensure' => 'file',
-    })
-    }
+  describe 'ppa depending on ppa, MODULES-1156' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
   end
 
   describe 'package_name => software-properties-common' do
@@ -38,7 +39,8 @@ describe 'apt::ppa', :type => :define do
     end
     let :params do
       {
-        :package_name => 'software-properties-common'
+        :package_name   => 'software-properties-common',
+        :package_manage => true,
       }
     end
     let :facts do
@@ -106,7 +108,9 @@ describe 'apt::ppa', :type => :define do
 
   describe 'apt included, no proxy' do
     let :pre_condition do
-      'class { "apt": }'
+      'class { "apt": }
+      apt::ppa { "ppa:foo2": }
+      '
     end
     let :facts do
       {
@@ -119,29 +123,62 @@ describe 'apt::ppa', :type => :define do
     end
     let :params do
       {
-        'options' => '',
+        :options        => '',
+        :package_manage => true,
+        :require        => 'Apt::Ppa[ppa:foo2]',
       }
     end
     let(:title) { 'ppa:foo' }
+    it { is_expected.to compile.with_all_deps }
     it { is_expected.to contain_package('software-properties-common') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
-      'environment' => [],
-      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => [],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
+  end
 
-    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
-      'ensure' => 'file',
+  describe 'apt included, proxy host' do
+    let :pre_condition do
+      'class { "apt":
+        proxy => { "host" => "localhost" },
+      }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        'options' => '',
+        'package_manage' => true,
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    it { is_expected.to contain_package('software-properties-common') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+      :environment => ['http_proxy=http://localhost:8080'],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
 
-  describe 'apt included, proxy' do
+  describe 'apt included, proxy host and port' do
     let :pre_condition do
-      'class { "apt": proxy_host => "example.com" }'
+      'class { "apt":
+        proxy => { "host" => "localhost", "port" => 8180 },
+      }'
     end
     let :facts do
       {
@@ -154,27 +191,59 @@ describe 'apt::ppa', :type => :define do
     end
     let :params do
       {
-        'release' => 'lucid',
+        :options => '',
+        :package_manage => true,
       }
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
-      'environment' => ['http_proxy=http://example.com:8080', 'https_proxy=http://example.com:8080'],
-      'command'     => '/usr/bin/add-apt-repository -y ppa:foo',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-lucid.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => ['http_proxy=http://localhost:8180'],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
+  end
 
-    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-lucid.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
-      'ensure' => 'file',
+  describe 'apt included, proxy host and port and https' do
+    let :pre_condition do
+      'class { "apt":
+        proxy => { "host" => "localhost", "port" => 8180, "https" => true },
+      }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        :options => '',
+        :package_manage => true,
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    it { is_expected.to contain_package('software-properties-common') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+      :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
 
   describe 'ensure absent' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
     let :facts do
       {
         :lsbdistrelease  => '14.04',
@@ -187,11 +256,11 @@ describe 'apt::ppa', :type => :define do
     let(:title) { 'ppa:foo' }
     let :params do
       {
-        'ensure' => 'absent'
+        :ensure => 'absent'
       }
     end
     it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'absent',
+      :ensure => 'absent',
     })
     }
   end
@@ -204,12 +273,13 @@ describe 'apt::ppa', :type => :define do
           :operatingsystem => 'Ubuntu',
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
+          :lsbdistcodeanme => nil,
         }
       end
       let(:title) { 'ppa:foo' }
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
       end
     end
@@ -217,18 +287,18 @@ describe 'apt::ppa', :type => :define do
     describe 'not ubuntu' do
       let :facts do
         {
-          :lsbdistrelease  => '14.04',
-          :lsbdistcodename => 'trusty',
+          :lsbdistrelease  => '6.0.7',
+          :lsbdistcodename => 'wheezy',
           :operatingsystem => 'Debian',
-          :lsbdistid       => 'Ubuntu',
+          :lsbdistid       => 'debian',
           :osfamily        => 'Debian',
         }
       end
       let(:title) { 'ppa:foo' }
       it do
         expect {
-          should compile
-        }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)
+          is_expected.to compile
+        }.to raise_error(Puppet::Error, /supported on Ubuntu and LinuxMint only/)
       end
     end
   end
diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb
new file mode 100644 (file)
index 0000000..6f09f9c
--- /dev/null
@@ -0,0 +1,115 @@
+require 'spec_helper'
+
+describe 'apt::setting' do
+  let(:pre_condition) { 'class { "apt": }' }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
+  let(:title) { 'conf-teddybear' }
+
+  let(:default_params) { { :content => 'di' } }
+
+  describe 'when using the defaults' do
+    context 'without source or content' do
+      it do
+        expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /)
+      end
+    end
+
+    context 'with title=conf-teddybear ' do
+      let(:params) { default_params }
+      it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
+    end
+
+    context 'with title=pref-teddybear' do
+      let(:title) { 'pref-teddybear' }
+      let(:params) { default_params }
+      it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') }
+    end
+
+    context 'with title=list-teddybear' do
+      let(:title) { 'list-teddybear' }
+      let(:params) { default_params }
+      it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') }
+    end
+
+    context 'with source' do
+      let(:params) { { :source => 'puppet:///la/die/dah' } }
+      it {
+        is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
+        :ensure => 'file',
+        :owner  => 'root',
+        :group  => 'root',
+        :mode   => '0644',
+        :source => "#{params[:source]}",
+      })}
+    end
+
+    context 'with content' do
+      let(:params) { default_params }
+      it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
+        :ensure  => 'file',
+        :owner   => 'root',
+        :group   => 'root',
+        :mode    => '0644',
+        :content => "#{params[:content]}",
+      })}
+    end
+  end
+
+  describe 'settings requiring settings, MODULES-769' do
+    let(:pre_condition) do
+      'class { "apt": }
+      apt::setting { "list-teddybear": content => "foo" }
+      '
+    end
+    let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
+    let(:title) { 'conf-teddybear' }
+    let(:default_params) { { :content => 'di' } }
+
+    let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) }
+
+    it { is_expected.to compile.with_all_deps }
+  end
+
+  describe 'when trying to pull one over' do
+    context 'with source and content' do
+      let(:params) { default_params.merge({ :source => 'la' }) }
+      it do
+        expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /)
+      end
+    end
+
+    context 'with title=ext-teddybear' do
+      let(:title) { 'ext-teddybear' }
+      let(:params) { default_params }
+      it do
+        expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /)
+      end
+    end
+
+    context 'with ensure=banana' do
+      let(:params) { default_params.merge({ :ensure => 'banana' }) }
+      it do
+        expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /)
+      end
+    end
+
+    context 'with priority=1.2' do
+      let(:params) { default_params.merge({ :priority => 1.2 }) }
+      it do
+        expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /)
+      end
+    end
+  end
+
+  describe 'with priority=100' do
+    let(:params) { default_params.merge({ :priority => 100 }) }
+    it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
+  end
+
+  describe 'with ensure=absent' do
+    let(:params) { default_params.merge({ :ensure => 'absent' }) }
+    it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
+      :ensure => 'absent',
+    })}
+  end
+end
index 8ca7f8e20308f763910b800e60c6c41db9a32d72..7fd86b56ff0ff35e98ff8a4e5abd90fdfb31c13b 100644 (file)
@@ -1,39 +1,49 @@
 require 'spec_helper'
 
-describe 'apt::source', :type => :define do
+describe 'apt::source' do
   GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
 
+  let :pre_condition do
+    'class { "apt": }'
+  end
 
   let :title do
     'my_source'
   end
 
-  context 'mostly defaults' do
-    let :facts do
-      {
-        :lsbdistid       => 'Debian',
-        :lsbdistcodename => 'wheezy',
-        :osfamily        => 'Debian'
-      }
+  context 'defaults' do
+    context 'without location' do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+          :lsbdistcodename => 'wheezy',
+          :osfamily        => 'Debian'
+        }
+      end
+      it do
+        expect {
+          is_expected.to compile
+        }.to raise_error(Puppet::Error, /source entry without specifying a location/)
+      end
     end
+    context 'with location' do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+          :lsbdistcodename => 'wheezy',
+          :osfamily        => 'Debian'
+        }
+      end
+      let(:params) { { :location => 'hello.there', } }
 
-    let :params do
-      {
-        'include_deb' => false,
+      it { is_expected.to contain_apt__setting('list-my_source').with({
+        :ensure  => 'present',
+      }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/)
       }
     end
-
-    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list.d/my_source.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    }).with_content(/# my_source\ndeb-src  wheezy main\n/)
-    }
   end
 
-  context 'no defaults' do
+  describe 'no defaults' do
     let :facts do
       {
         :lsbdistid       => 'Debian',
@@ -41,60 +51,112 @@ describe 'apt::source', :type => :define do
         :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,
+    context 'with simple key' do
+      let :params do
+        {
+          :comment           => 'foo',
+          :location          => 'http://debian.mirror.iweb.ca/debian/',
+          :release           => 'sid',
+          :repos             => 'testing',
+          :key               => GPG_KEY_ID,
+          :pin               => '10',
+          :architecture      => 'x86_64',
+          :allow_unsigned    => true,
+        }
+      end
+
+      it { is_expected.to contain_apt__setting('list-my_source').with({
+        :ensure => 'present',
+      }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+      }
+
+      it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure   => 'present',
+        :priority => '10',
+        :origin   => 'debian.mirror.iweb.ca',
+      })
+      }
+
+      it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure  => 'present',
+        :id      => GPG_KEY_ID,
+      })
       }
     end
 
-    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list.d/my_source.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
-    }
+    context 'with complex key' do
+      let :params do
+        {
+          :comment           => 'foo',
+          :location          => 'http://debian.mirror.iweb.ca/debian/',
+          :release           => 'sid',
+          :repos             => 'testing',
+          :key               => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
+                                  'content' => 'GPG key content',
+                                  'source'  => 'http://apt.puppetlabs.com/pubkey.gpg',},
+          :pin               => '10',
+          :architecture      => 'x86_64',
+          :allow_unsigned    => true,
+        }
+      end
 
-    it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
-      'ensure'   => 'present',
-      'priority' => '10',
-      'origin'   => 'debian.mirror.iweb.ca',
-    })
-    }
+      it { is_expected.to contain_apt__setting('list-my_source').with({
+        :ensure => 'present',
+      }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+      }
 
-    it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').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__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure   => 'present',
+        :priority => '10',
+        :origin   => 'debian.mirror.iweb.ca',
+      })
+      }
 
-    it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({
-      'ensure' => 'present',
-        'key'  => GPG_KEY_ID,
-        'key_server' => 'pgp.mit.edu',
-        'key_content' => 'GPG key content',
-        'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
-    })
-    }
+      it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure  => 'present',
+        :id      => GPG_KEY_ID,
+        :server  => 'pgp.mit.edu',
+        :content => 'GPG key content',
+        :source  => 'http://apt.puppetlabs.com/pubkey.gpg',
+      })
+      }
+    end
+
+    context 'with simple key' do
+      let :params do
+        {
+          :comment        => 'foo',
+          :location       => 'http://debian.mirror.iweb.ca/debian/',
+          :release        => 'sid',
+          :repos          => 'testing',
+          :key            => GPG_KEY_ID,
+          :pin            => '10',
+          :architecture   => 'x86_64',
+          :allow_unsigned => true,
+        }
+      end
+
+      it { is_expected.to contain_apt__setting('list-my_source').with({
+        :ensure => 'present',
+      }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+      }
+
+      it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure   => 'present',
+        :priority => '10',
+        :origin   => 'debian.mirror.iweb.ca',
+      })
+      }
+
+      it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
+        :ensure  => 'present',
+        :id      => GPG_KEY_ID,
+      })
+      }
+    end
   end
 
-  context 'trusted_source true' do
+  context 'allow_unsigned true' do
     let :facts do
       {
         :lsbdistid       => 'Debian',
@@ -104,18 +166,14 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'include_src'    => false,
-        'trusted_source' => true,
+        :location       => 'hello.there',
+        :allow_unsigned => true,
       }
     end
 
-    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list.d/my_source.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    }).with_content(/# my_source\ndeb \[trusted=yes\]  wheezy main\n/)
+    it { is_expected.to contain_apt__setting('list-my_source').with({
+      :ensure => 'present',
+    }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
     }
   end
 
@@ -129,21 +187,18 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'include_deb'  => false,
-        'architecture' => 'x86_64',
+        :location     => 'hello.there',
+        :include      => {'deb' => false, 'src' => true,},
+        :architecture => 'x86_64',
       }
     end
 
-    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list.d/my_source.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-    }).with_content(/# my_source\ndeb-src \[arch=x86_64 \]  wheezy main\n/)
+    it { is_expected.to contain_apt__setting('list-my_source').with({
+      :ensure => 'present',
+    }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/)
     }
   end
+
   context 'ensure => absent' do
     let :facts do
       {
@@ -154,12 +209,12 @@ describe 'apt::source', :type => :define do
     end
     let :params do
       {
-        'ensure' => 'absent',
+        :ensure => 'absent',
       }
     end
 
-    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'absent'
+    it { is_expected.to contain_apt__setting('list-my_source').with({
+      :ensure => 'absent'
     })
     }
   end
@@ -172,10 +227,11 @@ describe 'apt::source', :type => :define do
           :osfamily        => 'Debian'
         }
       end
+      let(:params) { { :location => 'hello.there', } }
 
       it do
         expect {
-          should compile
+          is_expected.to compile
         }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
       end
     end
index 6b2aa5d845b7235d2c41991293eb62b6bdb7eff1..56b8dadc62df21e4510faaa0c31711cf63531b41 100644 (file)
@@ -28,7 +28,7 @@ RSpec.configure do |c|
     hosts.each do |host|
       copy_module_to(host, :source => proj_root, :module_name => 'apt')
       shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
-      on host, puppet('module install puppetlabs-stdlib --version 2.2.1'), { :acceptable_exit_codes => [0,1] }
+      on host, puppet('module install puppetlabs-stdlib --version 4.5.0'), { :acceptable_exit_codes => [0,1] }
     end
   end
 end
index f8a3f20a1393add81b0605c220bb7d9773426277..b6eee265f77cbcb9e97854322053757c64319040 100644 (file)
@@ -8,7 +8,7 @@ describe 'apt_has_updates fact' do
     before {
       Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat'
     }
-    it { should be_nil }
+    it { is_expected.to be_nil }
   end
 
   describe 'on Debian based distro missing update-notifier-common' do
@@ -17,7 +17,7 @@ describe 'apt_has_updates fact' do
       File.stubs(:executable?) # Stub all other calls
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns false
     }
-    it { should be_nil }
+    it { is_expected.to be_nil }
   end
 
   describe 'on Debian based distro with broken packages' do
@@ -28,7 +28,7 @@ describe 'apt_has_updates fact' do
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
       Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Error: BrokenCount > 0"
     }
-    it { should be_nil }
+    it { is_expected.to be_nil }
   end
 
   describe 'on Debian based distro with unknown error with semicolons' do
@@ -39,7 +39,7 @@ describe 'apt_has_updates fact' do
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
       Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Unknown Error: 'This error contains something that could be parsed like 4;3' (10)"
     }
-    it { should be_nil }
+    it { is_expected.to be_nil }
   end
 
   describe 'on Debian based distro' do
@@ -50,7 +50,7 @@ describe 'apt_has_updates fact' do
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
       Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3"
     }
-    it { should be true }
+    it { is_expected.to be true }
   end
 end
 
index 5c7a624f4d7f2688ca367b62676870cfc35b70ce..08bfb42a342c70770303135ebd97d6cb20739fbd 100644 (file)
@@ -8,7 +8,7 @@ describe 'apt_package_updates fact' do
     before { 
       Facter.fact(:apt_has_updates).stubs(:value).returns false
     }
-    it { should be nil }
+    it { is_expected.to be nil }
   end
 
   describe 'when apt has updates' do
@@ -22,9 +22,9 @@ describe 'apt_package_updates fact' do
     }
     it {
       if Facter.version < '2.0.0'
-        should == 'puppet-common,linux-generic,linux-image-generic'
+        is_expected.to eq('puppet-common,linux-generic,linux-image-generic')
       else
-        should == ['puppet-common', 'linux-generic', 'linux-image-generic']
+        is_expected.to eq(['puppet-common', 'linux-generic', 'linux-image-generic'])
       end
     }
   end
index 4bc760f7898ca406a20053fcb61917aa6879063f..83aa6ff620bce2c5cb10b3fcb3fa09d439c00cb6 100644 (file)
@@ -8,7 +8,7 @@ describe 'apt_security_updates fact' do
     before { 
       Facter.fact(:apt_has_updates).stubs(:value).returns false
     }
-    it { should be nil }
+    it { is_expected.to be nil }
   end
 
   describe 'when apt has security updates' do
@@ -19,7 +19,7 @@ describe 'apt_security_updates fact' do
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
       Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7"
     }
-    it { should == 7 }
+    it { is_expected.to eq(7) }
   end
 
 end
index 08774cd012eb47bde480ec264970dc999c77656e..cb32a5ef02cf25d686c797375185ba80a9599530 100644 (file)
@@ -10,7 +10,7 @@ describe 'apt_update_last_success fact' do
       File.stubs(:exists?).returns false
     }
     it 'should have a value of -1' do
-      should == -1
+      is_expected.to eq(-1)
     end
   end
 
@@ -21,7 +21,7 @@ describe 'apt_update_last_success fact' do
       File.stubs(:mtime).returns 1407660561
     }
     it 'should have the value of the mtime of the file' do
-      should == 1407660561
+      is_expected.to eq(1407660561)
     end
   end
 
index 7e9b77f84f695cecb108c9cc9897ea7254d411a6..781ffd6972892d1b1e5f6077252593cdbac8e5c2 100644 (file)
@@ -8,7 +8,7 @@ describe 'apt_updates fact' do
     before { 
       Facter.fact(:apt_has_updates).stubs(:value).returns false
     }
-    it { should be nil }
+    it { is_expected.to be nil }
   end
 
   describe 'when apt has updates' do
@@ -19,7 +19,7 @@ describe 'apt_updates fact' do
       File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
       Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7"
     }
-    it { should == 14 }
+    it { is_expected.to eq(14) }
   end
 
 end
index e8a5462c6f3e91c002a208883fd4f3116344c66b..e412b5066478284b291b016871f9ba17e7e2d13c 100644 (file)
@@ -7,23 +7,23 @@ describe Puppet::Type::type(:apt_key) do
       :id => '4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      expect(resource[:id]).to eq '4BD6EC30'
     end
 
     it 'name is set to id' do
-      resource[:name].should eq '4BD6EC30'
+      expect(resource[:name]).to eq '4BD6EC30'
     end
 
     it 'keyserver is default' do
-      resource[:server].should eq :'keyserver.ubuntu.com'
+      expect(resource[:server]).to eq :'keyserver.ubuntu.com'
     end
 
     it 'source is not set' do
-      resource[:source].should eq nil
+      expect(resource[:source]).to eq nil
     end
 
     it 'content is not set' do
-      resource[:content].should eq nil
+      expect(resource[:content]).to eq nil
     end
   end
 
@@ -32,7 +32,7 @@ describe Puppet::Type::type(:apt_key) do
       :id => '4bd6ec30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      expect(resource[:id]).to eq '4BD6EC30'
     end
   end
 
@@ -41,7 +41,7 @@ describe Puppet::Type::type(:apt_key) do
       :id => 'FFFFFFFF4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq 'FFFFFFFF4BD6EC30'
+      expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30'
     end
   end
 
@@ -50,7 +50,7 @@ describe Puppet::Type::type(:apt_key) do
       :id => '0x4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      expect(resource[:id]).to eq '4BD6EC30'
     end
   end
 
@@ -59,7 +59,7 @@ describe Puppet::Type::type(:apt_key) do
       :id => '0x4bd6ec30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      expect(resource[:id]).to eq '4BD6EC30'
     end
   end
 
@@ -68,7 +68,7 @@ describe Puppet::Type::type(:apt_key) do
       :id => '0xFFFFFFFF4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq 'FFFFFFFF4BD6EC30'
+      expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30'
     end
   end
 
@@ -79,7 +79,7 @@ describe Puppet::Type::type(:apt_key) do
     )}
 
     it 'source is set to the URL' do
-      resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg'
+      expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg'
     end
   end
 
@@ -90,7 +90,7 @@ describe Puppet::Type::type(:apt_key) do
     )}
 
     it 'content is set to the string' do
-      resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg'
+      expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg'
     end
   end
 
@@ -101,7 +101,7 @@ describe Puppet::Type::type(:apt_key) do
     )}
 
     it 'keyserver is set to Debian' do
-      resource[:server].should eq 'http://keyring.debian.org'
+      expect(resource[:server]).to eq 'http://keyring.debian.org'
     end
   end
 
diff --git a/templates/10periodic.erb b/templates/10periodic.erb
deleted file mode 100644 (file)
index 43caed9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-APT::Periodic::Enable "<%= @enable %>";
-APT::Periodic::BackUpArchiveInterval "<%= @backup_interval %>";
-APT::Periodic::BackUpLevel "<%= @backup_level %>";
-APT::Periodic::MaxAge "<%= @max_age %>";
-APT::Periodic::MinAge "<%= @min_age %>";
-APT::Periodic::MaxSize "<%= @max_size %>";
-APT::Periodic::Update-Package-Lists "<%= @update %>";
-APT::Periodic::Download-Upgradeable-Packages "<%= @download %>";
-APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>";
-APT::Periodic::Unattended-Upgrade "<%= @upgrade %>";
-APT::Periodic::AutocleanInterval "<%= @autoclean %>";
-APT::Periodic::Verbose "<%= @verbose %>";
-<%- unless @randomsleep.nil? -%>
-APT::Periodic::RandomSleep "<%= @randomsleep %>";
-<%- end -%>
diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb
deleted file mode 100644 (file)
index 47ecb34..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Automatically upgrade packages from these (origin:archive) pairs
-<%- if @legacy_origin -%>
-Unattended-Upgrade::Allowed-Origins {
-<%- else -%>
-Unattended-Upgrade::Origins-Pattern {
-<%- end -%>
-<% @origins.each do |origin| -%>
-       "<%= origin %>";
-<% end -%>
-};
-
-// List of packages to not update
-Unattended-Upgrade::Package-Blacklist {
-<% @blacklist.each do |package| -%>
-       "<%= package %>";
-<% end -%>
-};
-
-// This option allows you to control if on a unclean dpkg exit
-// unattended-upgrades will automatically run 
-//   dpkg --force-confold --configure -a
-// The default is true, to ensure updates keep getting installed
-Unattended-Upgrade::AutoFixInterruptedDpkg "<%= @auto_fix %>";
-
-// Split the upgrade into the smallest possible chunks so that
-// they can be interrupted with SIGUSR1. This makes the upgrade
-// a bit slower but it has the benefit that shutdown while a upgrade
-// is running is possible (with a small delay)
-Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>";
-
-// Install all unattended-upgrades when the machine is shuting down
-// instead of doing it in the background while the machine is running
-// This will (obviously) make shutdown slower
-Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>";
-
-<% if @mail_to != "NONE" %>
-// Send email to this address for problems or packages upgrades
-// If empty or unset then no email is sent, make sure that you
-// have a working mail setup on your system. A package that provides
-// 'mailx' must be installed.
-Unattended-Upgrade::Mail "<%= @mail_to %>";
-<% end %>
-
-<% if @mail_to != "NONE" %>
-// Set this value to "true" to get emails only on errors. Default
-// is to always send a mail if Unattended-Upgrade::Mail is set
-Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";
-<% end %>
-
-// Do automatic removal of new unused dependencies after the upgrade
-// (equivalent to apt-get autoremove)
-Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>";
-
-// Automatically reboot *WITHOUT CONFIRMATION* if a
-// the file /var/run/reboot-required is found after the upgrade
-Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>";
-
-<% if @dl_limit != "NONE" %>
-// Use apt bandwidth limit feature, this example limits the download
-// speed to 70kb/sec
-Acquire::http::Dl-Limit "<%= @dl_limit %>";
-<% end %>
index 26b2516c47e9986edbbdefe5a225c6273c4f1c3d..76936d7ca47f0de45273dcdd6b4cd6317455069d 100644 (file)
@@ -15,7 +15,7 @@ elsif @origin.length > 0
   @pin = "origin #{@origin}"
 end
 -%>
-Explanation: <%= @explanation %>
+Explanation: <%= @_explanation %>
 Package: <%= @packages_string %>
 Pin: <%= @pin %>
 Pin-Priority: <%= @priority %>
diff --git a/templates/progressbar.erb b/templates/progressbar.erb
deleted file mode 100644 (file)
index d3d9278..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Dpkg::Progress-Fancy "1";
index accb0ccee8dad67ede066a86745a2373935ab75b..670e3a7e870fe24f7fa21e1e4a6147a29163a50b 100644 (file)
@@ -1 +1,4 @@
-Acquire::http::Proxy "http://<%= @proxy_host %>:<%= @proxy_port %>";
+Acquire::http::proxy "http://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/";
+<%- if @_proxy['https'] %>
+Acquire::https::proxy "https://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/";
+<%- end -%>
diff --git a/templates/release.erb b/templates/release.erb
deleted file mode 100644 (file)
index 08760af..0000000
+++ /dev/null
@@ -1 +0,0 @@
-APT::Default-Release "<%= @release_id %>";
index b50be8d1fd7601b3e2d4289d5f28f88793eb4962..26838db51b100fbe0380c2dbb826cf96067b4a6f 100644 (file)
@@ -1,11 +1,11 @@
 # <%= @comment %>
-<%- if @include_deb then -%>
-deb <%- if @architecture or @trusted_source -%>
-[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
-] <%- end %><%= @location %> <%= @release_real %> <%= @repos %>
+<%- if @_include['deb'] then -%>
+deb <%- if @architecture or @allow_unsigned -%>
+[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%>
+] <%- end %><%= @location %> <%= @release %> <%= @repos %>
 <%- end -%>
-<%- if @include_src then -%>
-deb-src <%- if @architecture or @trusted_source -%>
-[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%>
-] <%- end %><%= @location %> <%= @release_real %> <%= @repos %>
+<%- if @_include['src'] then -%>
+deb-src <%- if @architecture or @allow_unsigned -%>
+[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%>
+] <%- end %><%= @location %> <%= @release %> <%= @repos %>
 <%- end -%>
diff --git a/templates/unauth.erb b/templates/unauth.erb
deleted file mode 100644 (file)
index 77edd28..0000000
+++ /dev/null
@@ -1 +0,0 @@
-APT::Get::AllowUnauthenticated 1;
diff --git a/tests/builddep.pp b/tests/builddep.pp
deleted file mode 100644 (file)
index 8b4f796..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class { 'apt': }
-apt::builddep{ 'glusterfs-server': }
diff --git a/tests/debian/testing.pp b/tests/debian/testing.pp
deleted file mode 100644 (file)
index 8245b3a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class { 'apt': }
-class { 'apt::debian::testing': }
diff --git a/tests/debian/unstable.pp b/tests/debian/unstable.pp
deleted file mode 100644 (file)
index 8605179..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-class { 'apt': }
-class { 'apt::debian::unstable': }
diff --git a/tests/force.pp b/tests/force.pp
deleted file mode 100644 (file)
index 59ad8f1..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# force.pp
-
-# force a package from a specific release
-apt::force { 'package1':
-  release => 'backports',
-}
-
-# force a package to be a specific version
-apt::force { 'package2':
-  version => '1.0.0-1',
-}
-
-# force a package from a specific release to be a specific version
-apt::force { 'package3':
-  release => 'sid',
-  version => '2.0.0-1',
-}
diff --git a/tests/init.pp b/tests/init.pp
deleted file mode 100644 (file)
index abc75af..0000000
+++ /dev/null
@@ -1 +0,0 @@
-class { 'apt': }
diff --git a/tests/params.pp b/tests/params.pp
deleted file mode 100644 (file)
index 5ddf3c6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include apt::params
diff --git a/tests/release.pp b/tests/release.pp
deleted file mode 100644 (file)
index 823f586..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-class { 'apt': }
-class { 'apt::release':
-  release_id => 'karmic'
-}
diff --git a/tests/unattended_upgrades.pp b/tests/unattended_upgrades.pp
deleted file mode 100644 (file)
index 3b9b49e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include apt::unattended_upgrades