repositories:
"stdlib":
"repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
- "ref": "v2.2.1"
+ "ref": "4.5.0"
symlinks:
"apt": "#{source_dir}"
---
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:
* 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
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
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',
* `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 }
Note that you can also specify more complex pins using distribution properties.
- ```
+ ```puppet
apt::pin { 'stable':
priority => -10,
originator => 'Debian',
* `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.
* `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
-----------
--- /dev/null
+package{ 'glusterfs-server':
+ install_options => 'build-dep',
+}
--- /dev/null
+# force.pp
+# TODO: Update
--- /dev/null
+apt::pin { 'hold-vim':
+ packages => 'vim',
+ version => '2:7.4.488-5',
+ priority => 1001,
+}
--- /dev/null
+apt::conf { 'release':
+ content => 'APT::Default-Release "karmic";',
+ priority => '01',
+}
# 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]
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
+++ /dev/null
-# 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',
- }
-}
+++ /dev/null
-# 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'],
- }
-}
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'),
}
}
+++ /dev/null
-# 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',
- }
-}
+++ /dev/null
-# 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',
- }
-}
+++ /dev/null
-# 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,
- }
-}
+++ /dev/null
-# == 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',
- }
- }
-
-}
-# == 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',
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)
}
}
#
# === 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": }
}
}
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',
$distid = 'debian'
$distcodename = $::lsbdistcodename
}
- '': {
+ undef: {
fail('Unable to determine lsbdistid, is lsb-release installed?')
}
default: {
}
}
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
+ }
}
}
define apt::pin(
$ensure = present,
- $explanation = "${caller_module_name}: ${name}",
- $order = '',
+ $explanation = undef,
+ $order = undef,
$packages = '*',
$priority = 0,
$release = '', # a=
$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,
}
}
-
# According to man 5 apt_preferences:
# The files have either no or "pref" as filename extension
# and only contain alphanumeric, hyphen (-), underscore (_) and period
# 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'),
}
}
# 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')
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'],
- }
}
+++ /dev/null
-# 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'),
- }
-}
--- /dev/null
+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,
+ }
+}
# 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, '/')
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'],
- }
}
+++ /dev/null
-# 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'],
- }
-}
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 {
$_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
}
}
}
],
"dependencies": [
- {"name":"puppetlabs/stdlib","version_requirement":">= 2.2.1"}
+ {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0"}
]
}
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
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
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
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
'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
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
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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-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
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
+++ /dev/null
-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
-
+++ /dev/null
-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
+++ /dev/null
-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
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
"/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',
"/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',
+++ /dev/null
-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
+++ /dev/null
-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
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
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
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
} 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',
})
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',
})
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',
})
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/)
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/)
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/)
context "exceed character url" do
let :params do
{
- :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+ :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
}
end
it 'fails' do
context "incorrect port number url" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu:8008080'
+ :server => 'hkp://pgp.mit.edu:8008080'
}
end
it 'fails' do
context "incorrect protocol for url" do
let :params do
{
- :key_server => 'abc://pgp.mit.edu:80'
+ :server => 'abc://pgp.mit.edu:80'
}
end
it 'fails' do
context "missing port number url" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu:'
+ :server => 'hkp://pgp.mit.edu:'
}
end
it 'fails' do
context "url ending with a dot" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu.'
+ :server => 'hkp://pgp.mit.edu.'
}
end
it 'fails' do
end
context "url begin with a dash" do
let(:params) do{
- :key_server => "hkp://-pgp.mit.edu",
+ :server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
context 'invalid source' do
let :params do {
- :key_source => 'afp://puppetlabs.com/key.gpg',
+ :source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
expect { subject }.to raise_error(/does not match/)
context 'invalid content' do
let :params do {
- :key_content => [],
+ :content => [],
} end
it 'fails' do
expect { subject }.to raise_error(/is not a string/)
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/)
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/)
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
'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
'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
'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
'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',
})
}
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
end
it do
expect {
- should compile
+ is_expected.to compile
}.to raise_error(Puppet::Error, /Only integers are allowed/)
end
end
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
end
it do
expect {
- should compile
+ is_expected.to compile
}.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
end
end
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
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
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',
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
end
let :params do
{
- :package_name => 'software-properties-common'
+ :package_name => 'software-properties-common',
+ :package_manage => true,
}
end
let :facts do
describe 'apt included, no proxy' do
let :pre_condition do
- 'class { "apt": }'
+ 'class { "apt": }
+ apt::ppa { "ppa:foo2": }
+ '
end
let :facts 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
{
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',
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
: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
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
--- /dev/null
+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
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',
: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',
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
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
{
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
: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
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
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
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
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
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
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
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
}
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
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
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
File.stubs(:exists?).returns false
}
it 'should have a value of -1' do
- should == -1
+ is_expected.to eq(-1)
end
end
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
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
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
: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
:id => '4bd6ec30'
)}
it 'id is set' do
- resource[:id].should eq '4BD6EC30'
+ expect(resource[:id]).to eq '4BD6EC30'
end
end
:id => 'FFFFFFFF4BD6EC30'
)}
it 'id is set' do
- resource[:id].should eq 'FFFFFFFF4BD6EC30'
+ expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30'
end
end
:id => '0x4BD6EC30'
)}
it 'id is set' do
- resource[:id].should eq '4BD6EC30'
+ expect(resource[:id]).to eq '4BD6EC30'
end
end
:id => '0x4bd6ec30'
)}
it 'id is set' do
- resource[:id].should eq '4BD6EC30'
+ expect(resource[:id]).to eq '4BD6EC30'
end
end
:id => '0xFFFFFFFF4BD6EC30'
)}
it 'id is set' do
- resource[:id].should eq 'FFFFFFFF4BD6EC30'
+ expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30'
end
end
)}
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
)}
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
)}
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
+++ /dev/null
-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 -%>
+++ /dev/null
-// 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 %>
@pin = "origin #{@origin}"
end
-%>
-Explanation: <%= @explanation %>
+Explanation: <%= @_explanation %>
Package: <%= @packages_string %>
Pin: <%= @pin %>
Pin-Priority: <%= @priority %>
+++ /dev/null
-Dpkg::Progress-Fancy "1";
-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 -%>
+++ /dev/null
-APT::Default-Release "<%= @release_id %>";
# <%= @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 -%>
+++ /dev/null
-APT::Get::AllowUnauthenticated 1;
+++ /dev/null
-class { 'apt': }
-apt::builddep{ 'glusterfs-server': }
+++ /dev/null
-class { 'apt': }
-class { 'apt::debian::testing': }
+++ /dev/null
-class { 'apt': }
-class { 'apt::debian::unstable': }
+++ /dev/null
-# 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',
-}
+++ /dev/null
-class { 'apt': }
+++ /dev/null
-include apt::params
+++ /dev/null
-class { 'apt': }
-class { 'apt::release':
- release_id => 'karmic'
-}
+++ /dev/null
-include apt::unattended_upgrades