Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/manifests/init.pp b/manifests/init.pp
index 9c6a44b..f205b3e 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,321 +1,325 @@
# @summary Main class, includes all other classes.
#
# @see https://docs.puppetlabs.com/references/latest/function.html#createresources for the create resource function
#
# @param provider
# Specifies the provider that should be used by apt::update.
#
# @param keyserver
# Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or
# hkp://).
#
+# @param key_options
+# Specifies the default options for apt::key resources.
+#
# @param ppa_options
# Supplies options to be passed to the `add-apt-repository` command.
#
# @param ppa_package
# Names the package that provides the `apt-add-repository` command.
#
# @param backports
# Specifies some of the default parameters used by apt::backports. Valid options: a hash made up from the following keys:
#
# @option backports [String] :location
# See apt::backports for documentation.
#
# @option backports [String] :repos
# See apt::backports for documentation.
#
# @option backports [String] :key
# See apt::backports for documentation.
#
# @param confs
# Creates new `apt::conf` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param update
# Configures various update settings. Valid options: a hash made up from the following keys:
#
# @option update [String] :frequency
# Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value.
# Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400);
# 'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource
# `apt_update` is notified). Default: 'reluctantly'.
#
# @option update [Integer] :loglevel
# Specifies the log level of logs outputted to the console. Default: undef.
#
# @option update [Integer] :timeout
# Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: undef.
#
# @option update [Integer] :tries
# Specifies how many times to retry the update after receiving a DNS or HTTP error. Default: undef.
#
# @param purge
# Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys:
#
# @option purge [Boolean] :sources.list
# Specifies whether to purge any unmanaged entries from sources.list. Default false.
#
# @option purge [Boolean] :sources.list.d
# Specifies whether to purge any unmanaged entries from sources.list.d. Default false.
#
# @option purge [Boolean] :preferences
# Specifies whether to purge any unmanaged entries from preferences. Default false.
#
# @option purge [Boolean] :preferences.d.
# Specifies whether to purge any unmanaged entries from preferences.d. Default false.
#
# @param proxy
# Configures Apt to connect to a proxy server. Valid options: a hash matching the locally defined type apt::proxy.
#
# @param sources
# Creates new `apt::source` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param keys
# Creates new `apt::key` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param ppas
# Creates new `apt::ppa` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param pins
# Creates new `apt::pin` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param settings
# Creates new `apt::setting` resources. Valid options: a hash to be passed to the create_resources function linked above.
#
# @param manage_auth_conf
# Specifies whether to manage the /etc/apt/auth.conf file. When true, the file will be overwritten with the entries specified in
# the auth_conf_entries parameter. When false, the file will be ignored (note that this does not set the file to absent.
#
# @param auth_conf_entries
# An optional array of login configuration settings (hashes) that are recorded in the file /etc/apt/auth.conf. This file has a netrc-like
# format (similar to what curl uses) and contains the login configuration for APT sources and proxies that require authentication. See
# https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details. If specified each hash must contain the keys machine, login and
# password and no others. Specifying manage_auth_conf and not specifying this parameter will set /etc/apt/auth.conf to absent.
#
# @param auth_conf_owner
# The owner of the file /etc/apt/auth.conf. Default: '_apt' or 'root' on old releases.
#
# @param root
# Specifies root directory of Apt executable.
#
# @param sources_list
# Specifies the path of the sources_list file to use.
#
# @param sources_list_d
# Specifies the path of the sources_list.d file to use.
#
# @param conf_d
# Specifies the path of the conf.d file to use.
#
# @param preferences
# Specifies the path of the preferences file to use.
#
# @param preferences_d
# Specifies the path of the preferences.d file to use.
#
# @param config_files
# A hash made up of the various configuration files used by Apt.
#
class apt (
Hash $update_defaults = $apt::params::update_defaults,
Hash $purge_defaults = $apt::params::purge_defaults,
Hash $proxy_defaults = $apt::params::proxy_defaults,
Hash $include_defaults = $apt::params::include_defaults,
String $provider = $apt::params::provider,
String $keyserver = $apt::params::keyserver,
+ Optional[String] $key_options = $apt::params::key_options,
Optional[String] $ppa_options = $apt::params::ppa_options,
Optional[String] $ppa_package = $apt::params::ppa_package,
Optional[Hash] $backports = $apt::params::backports,
Hash $confs = $apt::params::confs,
Hash $update = $apt::params::update,
Hash $purge = $apt::params::purge,
Apt::Proxy $proxy = $apt::params::proxy,
Hash $sources = $apt::params::sources,
Hash $keys = $apt::params::keys,
Hash $ppas = $apt::params::ppas,
Hash $pins = $apt::params::pins,
Hash $settings = $apt::params::settings,
Boolean $manage_auth_conf = $apt::params::manage_auth_conf,
Array[Apt::Auth_conf_entry]
$auth_conf_entries = $apt::params::auth_conf_entries,
String $auth_conf_owner = $apt::params::auth_conf_owner,
String $root = $apt::params::root,
String $sources_list = $apt::params::sources_list,
String $sources_list_d = $apt::params::sources_list_d,
String $conf_d = $apt::params::conf_d,
String $preferences = $apt::params::preferences,
String $preferences_d = $apt::params::preferences_d,
String $apt_conf_d = $apt::params::apt_conf_d,
Hash $config_files = $apt::params::config_files,
Hash $source_key_defaults = $apt::params::source_key_defaults,
) inherits apt::params {
if $facts['osfamily'] != 'Debian' {
fail(translate('This module only works on Debian or derivatives like Ubuntu'))
}
if $update['frequency'] {
assert_type(
Enum['always','daily','weekly','reluctantly'],
$update['frequency'],
)
}
if $update['timeout'] {
assert_type(Integer, $update['timeout'])
}
if $update['tries'] {
assert_type(Integer, $update['tries'])
}
$_update = merge($::apt::update_defaults, $update)
include ::apt::update
if $purge['sources.list'] {
assert_type(Boolean, $purge['sources.list'])
}
if $purge['sources.list.d'] {
assert_type(Boolean, $purge['sources.list.d'])
}
if $purge['preferences'] {
assert_type(Boolean, $purge['preferences'])
}
if $purge['preferences.d'] {
assert_type(Boolean, $purge['preferences.d'])
}
if $purge['apt.conf.d'] {
assert_type(Boolean, $purge['apt.conf.d'])
}
$_purge = merge($::apt::purge_defaults, $purge)
$_proxy = merge($apt::proxy_defaults, $proxy)
$confheadertmp = epp('apt/_conf_header.epp')
$proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
$updatestamptmp = epp('apt/15update-stamp.epp')
if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
apt::setting { 'conf-proxy':
ensure => $_proxy['ensure'],
priority => '01',
content => "${confheadertmp}${proxytmp}",
}
}
$sources_list_content = $_purge['sources.list'] ? {
true => "# Repos managed by puppet.\n",
default => undef,
}
$preferences_ensure = $_purge['preferences'] ? {
true => absent,
default => file,
}
if $_update['frequency'] == 'always' {
Exec <| title=='apt_update' |> {
refreshonly => false,
}
}
apt::setting { 'conf-update-stamp':
priority => 15,
content => "${confheadertmp}${updatestamptmp}",
}
file { 'sources.list':
ensure => file,
path => $::apt::sources_list,
owner => root,
group => root,
mode => '0644',
content => $sources_list_content,
notify => Class['apt::update'],
}
file { 'sources.list.d':
ensure => directory,
path => $::apt::sources_list_d,
owner => root,
group => root,
mode => '0644',
purge => $_purge['sources.list.d'],
recurse => $_purge['sources.list.d'],
notify => Class['apt::update'],
}
file { 'preferences':
ensure => $preferences_ensure,
path => $::apt::preferences,
owner => root,
group => root,
mode => '0644',
notify => Class['apt::update'],
}
file { 'preferences.d':
ensure => directory,
path => $::apt::preferences_d,
owner => root,
group => root,
mode => '0644',
purge => $_purge['preferences.d'],
recurse => $_purge['preferences.d'],
notify => Class['apt::update'],
}
file { 'apt.conf.d':
ensure => directory,
path => $::apt::apt_conf_d,
owner => root,
group => root,
mode => '0644',
purge => $_purge['apt.conf.d'],
recurse => $_purge['apt.conf.d'],
notify => Class['apt::update'],
}
if $confs {
create_resources('apt::conf', $confs)
}
# manage sources if present
if $sources {
create_resources('apt::source', $sources)
}
# manage keys if present
if $keys {
create_resources('apt::key', $keys)
}
# manage ppas if present
if $ppas {
create_resources('apt::ppa', $ppas)
}
# manage settings if present
if $settings {
create_resources('apt::setting', $settings)
}
if $manage_auth_conf {
$auth_conf_ensure = $auth_conf_entries ? {
[] => 'absent',
default => 'present',
}
$auth_conf_tmp = epp('apt/auth_conf.epp')
file { '/etc/apt/auth.conf':
ensure => $auth_conf_ensure,
owner => $auth_conf_owner,
group => 'root',
mode => '0600',
content => "${confheadertmp}${auth_conf_tmp}",
notify => Class['apt::update'],
}
}
# manage pins if present
if $pins {
create_resources('apt::pin', $pins)
}
# required for adding GPG keys on Debian 9 (and derivatives)
ensure_packages(['dirmngr'])
}
diff --git a/manifests/key.pp b/manifests/key.pp
index 1f9a495..41e78e6 100644
--- a/manifests/key.pp
+++ b/manifests/key.pp
@@ -1,106 +1,106 @@
# @summary Manages the GPG keys that Apt uses to authenticate packages.
#
# @note
# The apt::key defined type makes use of the apt_key type, but includes extra functionality to help prevent duplicate keys.
#
# @example Declare Apt key for apt.puppetlabs.com source
# apt::key { 'puppetlabs':
# id => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
# server => 'hkps.pool.sks-keyservers.net',
# options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"',
# }
#
# @param id
# Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal
# characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters).
#
# @param ensure
# Specifies whether the key should exist. Valid options: 'present', 'absent' or 'refreshed'. Using 'refreshed' will make keys auto
# update when they have expired (assuming a new key exists on the key server).
#
# @param content
# Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient.
#
# @param source
# Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or
# an absolute path.
#
# @param server
# Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://,
# hkp:// or hkps://). The hkps:// protocol is currently only supported on Ubuntu 18.04.
#
# @param weak_ssl
# Specifies whether strict SSL verification on a https URL should be disabled. Valid options: true or false.
#
# @param options
# Passes additional options to `apt-key adv --keyserver-options`.
#
define apt::key (
Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/] $id = $title,
Enum['present', 'absent', 'refreshed'] $ensure = present,
Optional[String] $content = undef,
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $source = undef,
Pattern[/\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/] $server = $::apt::keyserver,
Boolean $weak_ssl = false,
- Optional[String] $options = undef,
+ Optional[String] $options = $::apt::key_options,
) {
case $ensure {
/^(refreshed|present)$/: {
if defined(Anchor["apt_key ${id} absent"]){
fail(translate('key with id %{_id} already ensured as absent'), {'_id' => id})
}
if !defined(Anchor["apt_key ${id} present"]) {
apt_key { $title:
ensure => present,
refresh => $ensure == 'refreshed',
id => $id,
source => $source,
content => $content,
server => $server,
weak_ssl => $weak_ssl,
options => $options,
} -> anchor { "apt_key ${id} present": }
case $facts['os']['name'] {
'Debian': {
if versioncmp($facts['os']['release']['major'], '9') >= 0 {
ensure_packages(['dirmngr'])
Apt::Key<| title == $title |>
}
}
'Ubuntu': {
if versioncmp($facts['os']['release']['full'], '17.04') >= 0 {
ensure_packages(['dirmngr'])
Apt::Key<| title == $title |>
}
}
default: { }
}
}
}
absent: {
if defined(Anchor["apt_key ${id} present"]){
fail(translate('key with id %{_id} already ensured as present', {'_id' => id}))
}
if !defined(Anchor["apt_key ${id} absent"]){
apt_key { $title:
ensure => $ensure,
id => $id,
source => $source,
content => $content,
server => $server,
weak_ssl => $weak_ssl,
options => $options,
} -> anchor { "apt_key ${id} absent": }
}
}
default: {
fail translate('Invalid \'ensure\' value \'%{_ensure}\' for apt::key', {'_ensure' => ensure})
}
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
index 65219fe..b0c367c 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,121 +1,122 @@
# @summary Provides defaults for the Apt module parameters.
#
# @api private
#
class apt::params {
if $::osfamily != 'Debian' {
fail(translate('This module only works on Debian or derivatives like Ubuntu'))
}
$root = '/etc/apt'
$provider = '/usr/bin/apt-get'
$sources_list = "${root}/sources.list"
$sources_list_d = "${root}/sources.list.d"
$trusted_gpg_d = "${root}/trusted.gpg.d"
$conf_d = "${root}/apt.conf.d"
$preferences = "${root}/preferences"
$preferences_d = "${root}/preferences.d"
$apt_conf_d = "${root}/apt.conf.d"
$keyserver = 'keyserver.ubuntu.com'
+ $key_options = undef
$confs = {}
$update = {}
$purge = {}
$proxy = {}
$sources = {}
$keys = {}
$ppas = {}
$pins = {}
$settings = {}
$manage_auth_conf = true
$auth_conf_entries = []
$config_files = {
'conf' => {
'path' => $conf_d,
'ext' => '',
},
'pref' => {
'path' => $preferences_d,
'ext' => '.pref',
},
'list' => {
'path' => $sources_list_d,
'ext' => '.list',
}
}
$update_defaults = {
'frequency' => 'reluctantly',
'loglevel' => undef,
'timeout' => undef,
'tries' => undef,
}
$proxy_defaults = {
'ensure' => undef,
'host' => undef,
'port' => 8080,
'https' => false,
'direct' => false,
}
$purge_defaults = {
'sources.list' => false,
'sources.list.d' => false,
'preferences' => false,
'preferences.d' => false,
'apt.conf.d' => false,
}
$source_key_defaults = {
'server' => $keyserver,
'options' => undef,
'content' => undef,
'source' => undef,
}
$include_defaults = {
'deb' => true,
'src' => false,
}
case $facts['os']['name']{
'Debian': {
$backports = {
'location' => 'http://deb.debian.org/debian',
'repos' => 'main contrib non-free',
}
$ppa_options = undef
$ppa_package = undef
if versioncmp($facts['os']['release']['major'], '9') >= 0 {
$auth_conf_owner = '_apt'
} else {
$auth_conf_owner = 'root'
}
}
'Ubuntu': {
$backports = {
'location' => 'http://archive.ubuntu.com/ubuntu',
'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5',
'repos' => 'main universe multiverse restricted',
}
$ppa_options = '-y'
$ppa_package = 'software-properties-common'
if versioncmp($facts['os']['release']['full'], '16.04') >= 0 {
$auth_conf_owner = '_apt'
} else {
$auth_conf_owner = 'root'
}
}
undef: {
fail(translate('Unable to determine value for fact os[\"name\"]'))
}
default: {
$ppa_options = undef
$ppa_package = undef
$backports = undef
$auth_conf_owner = 'root'
}
}
}
diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb
index 68d5fce..ad715d6 100644
--- a/spec/defines/key_spec.rb
+++ b/spec/defines/key_spec.rb
@@ -1,382 +1,408 @@
require 'spec_helper'
GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze
title_key_example = { id: GPG_KEY_ID,
ensure: 'present',
source: nil,
server: 'keyserver.ubuntu.com',
content: nil,
options: nil }
def default_apt_key_example(title)
{ id: title,
ensure: 'present',
source: nil,
server: 'keyserver.ubuntu.com',
content: nil,
options: nil,
refresh: false }
end
def bunch_things_apt_key_example(title, params)
{ id: title,
ensure: 'present',
source: 'http://apt.puppetlabs.com/pubkey.gpg',
server: 'pgp.mit.edu',
content: params[:content],
options: 'debug' }
end
def absent_apt_key(title)
{ id: title,
ensure: 'absent',
source: nil,
server: 'keyserver.ubuntu.com',
content: nil,
keyserver: nil }
end
describe 'apt::key' do
let :pre_condition do
'class { "apt": }'
end
let(:facts) do
{
os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
lsbdistcodename: 'jessie',
}
end
let :title do
GPG_KEY_ID
end
describe 'normal operation' do
describe 'default options' do
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(default_apt_key_example(title))
end
it 'contains the apt_key present anchor' do
is_expected.to contain_anchor("apt_key #{title} present")
end
end
describe 'title and key =>' do
let :title do
'puppetlabs'
end
let :params do
{
id: GPG_KEY_ID,
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(title_key_example)
end
it 'contains the apt_key present anchor' do
is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present")
end
end
describe 'ensure => absent' do
let :params do
{
ensure: 'absent',
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(absent_apt_key(title))
end
it 'contains the apt_key absent anchor' do
is_expected.to contain_anchor("apt_key #{title} absent")
end
end
describe 'ensure => refreshed' do
let :params do
{
ensure: 'refreshed',
}
end
it 'contains the apt_key with refresh => true' do
is_expected.to contain_apt_key(title).with(
ensure: 'present',
refresh: true,
)
end
end
describe 'set a bunch of things!' do
let :params do
{
content: 'GPG key content',
source: 'http://apt.puppetlabs.com/pubkey.gpg',
server: 'pgp.mit.edu',
options: 'debug',
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params))
end
it 'contains the apt_key present anchor' do
is_expected.to contain_anchor("apt_key #{title} present")
end
end
context 'when domain with dash' do
let(:params) do
{
server: 'p-gp.m-it.edu',
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(id: title,
server: 'p-gp.m-it.edu')
end
end
context 'with url' do
let :params do
{
server: 'hkp://pgp.mit.edu',
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(id: title,
server: 'hkp://pgp.mit.edu')
end
end
context 'when url with port number' do
let :params do
{
server: 'hkp://pgp.mit.edu:80',
}
end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with(id: title,
server: 'hkp://pgp.mit.edu:80')
end
end
end
describe 'validation' do
context 'when domain begin with dash' do
let(:params) do
{
server: '-pgp.mit.edu',
}
end
it 'fails' do
is_expected .to raise_error(%r{expects a match})
end
end
context 'when domain begin with dot' do
let(:params) do
{
server: '.pgp.mit.edu',
}
end
it 'fails' do
is_expected .to raise_error(%r{expects a match})
end
end
context 'when domain end with dot' do
let(:params) do
{
server: 'pgp.mit.edu.',
}
end
it 'fails' do
is_expected .to raise_error(%r{expects a match})
end
end
context 'when character url exceeded' do
let :params do
{
server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with incorrect port number url' do
let :params do
{
server: 'hkp://pgp.mit.edu:8008080',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with incorrect protocol for url' do
let :params do
{
server: 'abc://pgp.mit.edu:80',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with missing port number url' do
let :params do
{
server: 'hkp://pgp.mit.edu:',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with url ending with a dot' do
let :params do
{
server: 'hkp://pgp.mit.edu.',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'when url begins with a dash' do
let(:params) do
{
server: 'hkp://-pgp.mit.edu',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with invalid key' do
let :title do
'Out of rum. Why? Why are we out of rum?'
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with invalid source' do
let :params do
{
source: 'afp://puppetlabs.com/key.gpg',
}
end
it 'fails' do
is_expected.to raise_error(%r{evaluating a Resource})
end
end
context 'with invalid content' do
let :params do
{
content: [],
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a})
end
end
context 'with invalid server' do
let :params do
{
server: 'two bottles of rum',
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a match})
end
end
context 'with invalid options' do
let :params do
{
options: {},
}
end
it 'fails' do
is_expected.to raise_error(%r{expects a})
end
end
context 'with invalid ensure' do
['foo', 'aabsent', 'absenta', 'apresent', 'presenta', 'refresh', 'arefreshed', 'refresheda'].each do |param|
let :params do
{
ensure: param,
}
end
it 'fails' do
is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got})
end
end
end
describe 'duplication - two apt::key resources for same key, different titles' do
let :pre_condition do
"class { 'apt': }
apt::key { 'duplicate': id => '#{title}', }"
end
it 'contains two apt::key resource - duplicate' do
is_expected.to contain_apt__key('duplicate').with(id: title,
ensure: 'present')
end
it 'contains two apt::key resource - title' do
is_expected.to contain_apt__key(title).with(id: title,
ensure: 'present')
end
it 'contains only a single apt_key - duplicate' do
is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title))
end
it 'contains only a single apt_key - no title' do
is_expected.not_to contain_apt_key(title)
end
end
describe 'duplication - two apt::key resources, different ensure' do
let :pre_condition do
"class { 'apt': }
apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
is_expected.to raise_error(%r{already ensured as absent})
end
end
end
+
+ describe 'defaults' do
+ context 'when setting keyserver on the apt class' do
+ let :pre_condition do
+ 'class { "apt":
+ keyserver => "keyserver.example.com",
+ }'
+ end
+
+ it 'uses default keyserver' do
+ is_expected.to contain_apt_key(title).with_server('keyserver.example.com')
+ end
+ end
+
+ context 'when setting key_options on the apt class' do
+ let :pre_condition do
+ 'class { "apt":
+ key_options => "http-proxy=http://proxy.example.com:8080",
+ }'
+ end
+
+ it 'uses default keyserver' do
+ is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080')
+ end
+ end
+ end
end

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 18, 4:38 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3318308

Event Timeline