class apt::backports (
- Optional[Variant[String, Stdlib::Compat::String]] $location = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $release = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $repos = undef,
- Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key = undef,
- Optional[Variant[Integer, Stdlib::Compat::Integer, String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $pin = 200,
+ Optional[String] $location = undef,
+ Optional[String] $release = undef,
+ Optional[String] $repos = undef,
+ Optional[Variant[String, Hash]] $key = undef,
+ Optional[Variant[Integer, String, Hash]] $pin = 200,
){
if $location {
- validate_legacy(String, 'validate_string', $location)
$_location = $location
}
if $release {
- validate_legacy(String, 'validate_string', $release)
$_release = $release
}
if $repos {
- validate_legacy(String, 'validate_string', $repos)
$_repos = $repos
}
if $key {
- unless is_hash($key) {
- validate_legacy(String, 'validate_string', $key)
- }
$_key = $key
}
if ($facts['lsbdistid'] == 'Debian' or $facts['lsbdistid'] == 'Ubuntu') {
define apt::conf (
- Optional[Variant[String, Stdlib::Compat::String]] $content = undef,
- Enum['present', 'absent'] $ensure = present,
- Variant[String, Stdlib::Compat::String, Integer, Stdlib::Compat::Integer] $priority = 50,
- Optional[Boolean] $notify_update = undef,
+ Optional[String] $content = undef,
+ Enum['present', 'absent'] $ensure = present,
+ Variant[String, Integer] $priority = 50,
+ Optional[Boolean] $notify_update = undef,
) {
unless $ensure == 'absent' {
# Manage APT (Advanced Packaging Tool)
#
class apt (
- Variant[Hash, Stdlib::Compat::Hash] $update_defaults,
- Variant[Hash, Stdlib::Compat::Hash] $purge_defaults,
- Variant[Hash, Stdlib::Compat::Hash] $proxy_defaults,
- Variant[Hash, Stdlib::Compat::Hash] $include_defaults,
- Variant[String, Stdlib::Compat::String] $provider,
- Variant[String, Stdlib::Compat::String] $keyserver,
- Optional[Variant[String, Stdlib::Compat::String]] $ppa_options,
- Optional[Variant[String, Stdlib::Compat::String]] $ppa_package,
- Optional[Variant[Hash, Stdlib::Compat::Hash]] $backports,
- Variant[Hash, Stdlib::Compat::Hash] $confs = {},
- Variant[Hash, Stdlib::Compat::Hash] $update = {},
- Variant[Hash, Stdlib::Compat::Hash] $purge = {},
- Variant[Hash, Stdlib::Compat::Hash] $proxy = {},
- Variant[Hash, Stdlib::Compat::Hash] $sources = {},
- Variant[Hash, Stdlib::Compat::Hash] $keys = {},
- Variant[Hash, Stdlib::Compat::Hash] $ppas = {},
- Variant[Hash, Stdlib::Compat::Hash] $pins = {},
- Variant[Hash, Stdlib::Compat::Hash] $settings = {},
- Variant[String, Stdlib::Compat::String] $root = '/etc/apt',
- Variant[String, Stdlib::Compat::String] $sources_list = "${root}/sources.list",
- Variant[String, Stdlib::Compat::String] $sources_list_d = "${root}/sources.list.d",
- Variant[String, Stdlib::Compat::String] $conf_d = "${root}/apt.conf.d",
- Variant[String, Stdlib::Compat::String] $preferences = "${root}/preferences",
- Variant[String, Stdlib::Compat::String] $preferences_d = "${root}/preferences.d",
- Variant[Hash, Stdlib::Compat::Hash] $config_files = { conf => { path => $conf_d, ext => '' }, pref => { path => $preferences_d, ext => '.pref' }, list => { path => $sources_list_d, ext => '.list' } },
- Variant[Hash, Stdlib::Compat::Hash] $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef },
+ Hash $update_defaults,
+ Hash $purge_defaults,
+ Hash $proxy_defaults,
+ Hash $include_defaults,
+ String $provider,
+ String $keyserver,
+ Optional[String] $ppa_options,
+ Optional[String] $ppa_package,
+ Optional[Hash] $backports,
+ Hash $confs = {},
+ Hash $update = {},
+ Hash $purge = {},
+ Hash $proxy = {},
+ Hash $sources = {},
+ Hash $keys = {},
+ Hash $ppas = {},
+ Hash $pins = {},
+ Hash $settings = {},
+ String $root = '/etc/apt',
+ String $sources_list = "${root}/sources.list",
+ String $sources_list_d = "${root}/sources.list.d",
+ String $conf_d = "${root}/apt.conf.d",
+ String $preferences = "${root}/preferences",
+ String $preferences_d = "${root}/preferences.d",
+ Hash $config_files = { conf => { path => $conf_d, ext => '' }, pref => { path => $preferences_d, ext => '.pref' }, list => { path => $sources_list_d, ext => '.list' } },
+ Hash $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef },
) {
if $facts['osfamily'] != 'Debian' {
}
$frequency_options = ['always','daily','weekly','reluctantly']
- validate_legacy(Hash, 'validate_hash', $update)
+
if $update['frequency'] {
validate_re($update['frequency'], $frequency_options)
}
if $update['timeout'] {
- unless is_integer($update['timeout']) {
- fail('timeout value for update must be an integer')
- }
+ assert_type(Integer, $update['timeout'])
}
if $update['tries'] {
- unless is_integer($update['tries']) {
- fail('tries value for update must be an integer')
- }
+ assert_type(Integer, $update['tries'])
}
$_update = merge($::apt::update_defaults, $update)
include ::apt::update
- validate_legacy(Hash, 'validate_hash', $purge)
if $purge['sources.list'] {
- validate_legacy(Boolean, 'validate_bool', $purge['sources.list'])
+ assert_type(Boolean, $purge['sources.list'])
}
if $purge['sources.list.d'] {
- validate_legacy(Boolean, 'validate_bool', $purge['sources.list.d'])
+ assert_type(Boolean, $purge['sources.list.d'])
}
if $purge['preferences'] {
- validate_legacy(Boolean, 'validate_bool', $purge['preferences'])
+ assert_type(Boolean, $purge['preferences'])
}
if $purge['preferences.d'] {
- validate_legacy(Boolean, 'validate_bool', $purge['preferences.d'])
+ assert_type(Boolean, $purge['preferences.d'])
}
$_purge = merge($::apt::purge_defaults, $purge)
- validate_hash($proxy)
if $proxy['ensure'] {
validate_re($proxy['ensure'], ['file', 'present', 'absent'])
}
if $proxy['host'] {
- validate_legacy(String, 'validate_string', $proxy['host'])
+ assert_type(String, $proxy['host'])
}
if $proxy['port'] {
- unless is_integer($proxy['port']) {
- fail('$proxy port must be an integer')
- }
+ assert_type(Integer, $proxy['port'])
}
- if $proxy['https'] {
- validate_legacy(Boolean, 'validate_bool', $proxy['https'])
+ if $proxy['https']{
+ assert_type(Boolean, $proxy['https'])
}
$_proxy = merge($apt::proxy_defaults, $proxy)
- validate_legacy(Hash, 'validate_hash', $confs)
- validate_legacy(Hash, 'validate_hash', $sources)
- validate_legacy(Hash, 'validate_hash', $keys)
- validate_legacy(Hash, 'validate_hash', $settings)
- validate_legacy(Hash, 'validate_hash', $ppas)
- validate_legacy(Hash, 'validate_hash', $pins)
-
$confheadertmp = epp('apt/_conf_header.epp')
$proxytmp = epp('apt/proxy.epp', {'proxies' => $_proxy})
$updatestamptmp = epp('apt/15update-stamp.epp')
# == Define: apt::key
define apt::key (
- Variant[String, Stdlib::Compat::String] $id = $title,
- Enum['present', 'absent'] $ensure = present,
- Optional[Variant[String, Stdlib::Compat::String]] $content = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $source = undef,
- Variant[String, Stdlib::Compat::String] $server = $::apt::keyserver,
- Optional[Variant[String, Stdlib::Compat::String]] $options = undef,
- Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_content = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_source = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_server = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_options = undef,
+ String $id = $title,
+ Enum['present', 'absent'] $ensure = present,
+ Optional[String] $content = undef,
+ Optional[String] $source = undef,
+ String $server = $::apt::keyserver,
+ Optional[String] $options = undef,
) {
- if $key != undef {
- deprecation('apt $key', '$key is deprecated and will be removed in the next major release. Please use $id instead.')
- $_id = $key
- } else {
- $_id = $id
- }
-
- if $key_content != undef {
- deprecation('apt $key_content', '$key_content is deprecated and will be removed in the next major release. Please use $content instead.')
- $_content = $key_content
- } else {
- $_content = $content
- }
-
- if $key_source != undef {
- deprecation('apt $key_source', '$key_source is deprecated and will be removed in the next major release. Please use $source instead.')
- $_source = $key_source
- } else {
- $_source = $source
- }
-
- if $key_server != undef {
- deprecation('apt $key_server', '$key_server is deprecated and will be removed in the next major release. Please use $server instead.')
- $_server = $key_server
- } else {
- $_server = $server
- }
-
- if $key_options != undef {
- deprecation('apt $key_options', '$key_options is deprecated and will be removed in the next major release. Please use $options instead.')
- $_options = $key_options
- } else {
- $_options = $options
- }
-
- validate_re($_id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
- validate_re($ensure, ['\A(absent|present)\Z',])
-
- if $_content {
- validate_legacy(String, 'validate_string', $_content)
- }
-
- if $_source {
- validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
- }
+ validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
- if $_server {
- validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
+ if $source {
+ validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+'])
}
- if $_options {
- validate_legacy(String, 'validate_string', $_options)
+ if $server {
+ validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$'])
}
case $ensure {
present: {
- if defined(Anchor["apt_key ${_id} absent"]){
- fail("key with id ${_id} already ensured as absent")
+ if defined(Anchor["apt_key ${id} absent"]){
+ fail("key with id ${id} already ensured as absent")
}
- if !defined(Anchor["apt_key ${_id} present"]) {
+ if !defined(Anchor["apt_key ${id} present"]) {
apt_key { $title:
ensure => $ensure,
- id => $_id,
- source => $_source,
- content => $_content,
- server => $_server,
- options => $_options,
- } -> anchor { "apt_key ${_id} present": }
+ id => $id,
+ source => $source,
+ content => $content,
+ server => $server,
+ options => $options,
+ } -> anchor { "apt_key ${id} present": }
}
}
absent: {
- if defined(Anchor["apt_key ${_id} present"]){
- fail("key with id ${_id} already ensured as present")
+ if defined(Anchor["apt_key ${id} present"]){
+ fail("key with id ${id} already ensured as present")
}
- if !defined(Anchor["apt_key ${_id} absent"]){
+ if !defined(Anchor["apt_key ${id} absent"]){
apt_key { $title:
ensure => $ensure,
- id => $_id,
- source => $_source,
- content => $_content,
- server => $_server,
- options => $_options,
- } -> anchor { "apt_key ${_id} absent": }
+ id => $id,
+ source => $source,
+ content => $content,
+ server => $server,
+ options => $options,
+ } -> anchor { "apt_key ${id} absent": }
}
}
# pin a release in apt, useful for unstable repositories
define apt::pin(
- Optional[Enum['file', 'present', 'absent']] $ensure = present,
- Optional[Variant[String, Stdlib::Compat::String]] $explanation = undef,
- Variant[Integer, Stdlib::Compat::Integer] $order = 50,
- Variant[String, Stdlib::Compat::String, Stdlib::Compat::Array, Array] $packages = '*',
- Variant[Numeric, String, Stdlib::Compat::String] $priority = 0,
- Optional[Variant[String, Stdlib::Compat::String]] $release = '', # a=
- Optional[Variant[String, Stdlib::Compat::String]] $origin = '',
- Optional[Variant[String, Stdlib::Compat::String]] $version = '',
- Optional[Variant[String, Stdlib::Compat::String]] $codename = '', # n=
- Optional[Variant[String, Stdlib::Compat::String]] $release_version = '', # v=
- Optional[Variant[String, Stdlib::Compat::String]] $component = '', # c=
- Optional[Variant[String, Stdlib::Compat::String]] $originator = '', # o=
- Optional[Variant[String, Stdlib::Compat::String]] $label = '', # l=
+ Optional[Enum['file', 'present', 'absent']] $ensure = present,
+ Optional[String] $explanation = undef,
+ Variant[Integer] $order = 50,
+ Variant[String, Array] $packages = '*',
+ Variant[Numeric, String] $priority = 0,
+ Optional[String] $release = '', # a=
+ Optional[String] $origin = '',
+ Optional[String] $version = '',
+ Optional[String] $codename = '', # n=
+ Optional[String] $release_version = '', # v=
+ Optional[String] $component = '', # c=
+ Optional[String] $originator = '', # o=
+ Optional[String] $label = '', # l=
) {
if $explanation {
# ppa.pp
define apt::ppa(
- Variant[String, Stdlib::Compat::String] $ensure = 'present',
- Optional[Variant[String, Stdlib::Compat::String]] $options = $::apt::ppa_options,
- Optional[Variant[String, Stdlib::Compat::String]] $release = $facts['lsbdistcodename'],
- Optional[Variant[String, Stdlib::Compat::String]] $package_name = $::apt::ppa_package,
- Boolean $package_manage = false,
+ String $ensure = 'present',
+ Optional[String] $options = $::apt::ppa_options,
+ Optional[String] $release = $facts['lsbdistcodename'],
+ Optional[String] $package_name = $::apt::ppa_package,
+ Boolean $package_manage = false,
) {
unless $release {
fail('lsbdistcodename fact not available: release parameter required')
define apt::setting (
- Variant[String, Stdlib::Compat::String, Integer, Stdlib::Compat::Integer, Array, Stdlib::Compat::Array] $priority = 50,
- Optional[Enum['file', 'present', 'absent']] $ensure = file,
- Optional[Variant[String, Stdlib::Compat::String]] $source = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $content = undef,
- Optional[Boolean] $notify_update = true,
-
+ Variant[String, Integer, Array] $priority = 50,
+ Optional[Enum['file', 'present', 'absent']] $ensure = file,
+ Optional[String] $source = undef,
+ Optional[String] $content = undef,
+ Boolean $notify_update = true,
) {
if $content and $source {
fail('apt::setting needs either of content or source')
}
- if $notify_update {
- validate_legacy(Boolean, 'validate_bool', $notify_update)
- }
-
$title_array = split($title, '-')
$setting_type = $title_array[0]
$base_name = join(delete_at($title_array, 0), '-')
validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer')
}
- if $source {
- validate_legacy(String, 'validate_string', $source)
- }
-
- if $content {
- validate_legacy(String, 'validate_string', $content)
- }
-
if ($setting_type == 'list') or ($setting_type == 'pref') {
$_priority = ''
} else {
# source.pp
# add an apt source
define apt::source(
- Optional[Variant[String, Stdlib::Compat::String]] $location = undef,
- Variant[String, Stdlib::Compat::String] $comment = $name,
- Variant[String, Stdlib::Compat::String] $ensure = present,
- Optional[Variant[String, Stdlib::Compat::String]] $release = undef,
- Variant[String, Stdlib::Compat::String] $repos = 'main',
- Optional[Variant[Hash, Stdlib::Compat::Hash]] $include = {},
- Optional[Variant[String, Stdlib::Compat::String, Hash, Stdlib::Compat::Hash]] $key = undef,
- $pin = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $architecture = undef,
- Boolean $allow_unsigned = false,
- Boolean $notify_update = true,
- Optional[Variant[String, Stdlib::Compat::String]] $key_server = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_content = undef,
- Optional[Variant[String, Stdlib::Compat::String]] $key_source = undef,
- Optional[Boolean] $include_src = undef,
- Optional[Boolean] $include_deb = undef,
- $required_packages = undef,
- $trusted_source = undef,
+ Optional[String] $location = undef,
+ String $comment = $name,
+ String $ensure = present,
+ Optional[String] $release = undef,
+ String $repos = 'main',
+ Optional[Variant[Hash]] $include = {},
+ Optional[Variant[String, Hash]] $key = undef,
+ $pin = undef,
+ Optional[String] $architecture = undef,
+ Boolean $allow_unsigned = false,
+ Boolean $notify_update = true,
) {
- validate_legacy(String, 'validate_string', $architecture, $comment, $location, $repos)
- validate_legacy(Boolean, 'validate_bool', $allow_unsigned)
- validate_legacy(Hash, 'validate_hash', $include)
-
# This is needed for compat with 1.8.x
include ::apt
$_before = Apt::Setting["list-${title}"]
- if $required_packages != undef {
- deprecation('apt $required_packages', '$required_packages is deprecated and will be removed in the next major release, please use package resources instead.')
- exec { "Required packages: '${required_packages}' for ${name}":
- command => "${::apt::provider} -y install ${required_packages}",
- logoutput => 'on_failure',
- refreshonly => true,
- tries => 3,
- try_sleep => 1,
- before => $_before,
- }
- }
-
- if $trusted_source != undef {
- deprecation('apt $trusted_source', '$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.')
- $_allow_unsigned = $trusted_source
- } else {
- $_allow_unsigned = $allow_unsigned
- }
-
if ! $release {
if $facts['lsbdistcodename'] {
$_release = $facts['lsbdistcodename']
fail('cannot create a source entry without specifying a location')
}
- if $include_src != undef and $include_deb != undef {
- $_deprecated_include = {
- 'src' => $include_src,
- 'deb' => $include_deb,
- }
- } elsif $include_src != undef {
- $_deprecated_include = { 'src' => $include_src }
- } elsif $include_deb != undef {
- $_deprecated_include = { 'deb' => $include_deb }
- } else {
- $_deprecated_include = {}
- }
-
- $includes = merge($::apt::include_defaults, $_deprecated_include, $include)
-
- $_deprecated_key = {
- 'key_server' => $key_server,
- 'key_content' => $key_content,
- 'key_source' => $key_source,
- }
+ $includes = merge($::apt::include_defaults, $include)
if $key {
if is_hash($key) {
unless $key['id'] {
fail('key hash must contain at least an id entry')
}
- $_key = merge($::apt::source_key_defaults, $_deprecated_key, $key)
+ $_key = merge($::apt::source_key_defaults, $key)
} else {
validate_legacy(String, 'validate_string', $key)
- $_key = merge( { 'id' => $key }, $_deprecated_key)
+ $_key = { 'id' => $key }
}
}
'comment' => $comment,
'includes' => $includes,
'opt_architecture' => $architecture,
- 'allow_unsigned' => $_allow_unsigned,
+ 'allow_unsigned' => $allow_unsigned,
'location' => $location,
'release' => $_release,
'repos' => $repos,
if $key and ($ensure == 'present') {
if is_hash($_key) {
apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}":
- ensure => present,
- id => $_key['id'],
- server => $_key['server'],
- content => $_key['content'],
- source => $_key['source'],
- options => $_key['options'],
- key_server => $_key['key_server'],
- key_content => $_key['key_content'],
- key_source => $_key['key_source'],
- before => $_before,
+ ensure => present,
+ id => $_key['id'],
+ server => $_key['server'],
+ content => $_key['content'],
+ source => $_key['source'],
+ options => $_key['options'],
+ before => $_before,
}
}
}
{
"name": "puppetlabs-apt",
- "version": "3.0.0",
+ "version": "4.0.0",
"author": "Puppet Labs",
"summary": "Provides an interface for managing Apt source, key, and definitions with Puppet",
"license": "Apache-2.0",
class { 'apt':
update => {
'frequency' => 'always',
- 'timeout' => '400',
- 'tries' => '3',
+ 'timeout' => 400,
+ 'tries' => 3,
},
purge => {
'sources.list' => true,
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /expects a String value/)
+ }.to raise_error(Puppet::Error, /expects a/)
end
end
context 'invalid release' do
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /expects a String value/)
+ }.to raise_error(Puppet::Error, /expects a/)
end
end
context 'invalid repos' do
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /expects a String value/)
+ }.to raise_error(Puppet::Error, /expects a/)
end
end
context 'invalid key' do
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /expects a value of type String, Hash,/)
+ }.to raise_error(Puppet::Error, /expects a/)
end
end
context 'invalid pin' do
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /parameter 'pin' expects a value of type Integer, Pattern/)
+ }.to raise_error(Puppet::Error, /expects a/)
end
end
end
:source => nil,
:server => 'keyserver.ubuntu.com',
:content => nil,
- :keyserver_options => nil,
})
}
it 'contains the apt_key present anchor' do
end
let :params do {
- :key => GPG_KEY_ID,
+ :id => GPG_KEY_ID,
} end
it 'contains the apt_key' do
:source => nil,
:server => 'keyserver.ubuntu.com',
:content => nil,
- :keyserver_options => nil,
})
end
it 'contains the apt_key present anchor' do
:source => nil,
:server => 'keyserver.ubuntu.com',
:content => nil,
- :keyserver_options => nil,
})
end
it 'contains the apt_key absent anchor' do
describe 'set a bunch of things!' do
let :params do {
- :key_content => 'GPG key content',
- :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
- :key_server => 'pgp.mit.edu',
- :key_options => 'debug',
+ :content => 'GPG key content',
+ :source => 'http://apt.puppetlabs.com/pubkey.gpg',
+ :server => 'pgp.mit.edu',
+ :options => 'debug',
} end
it 'contains the apt_key' do
:ensure => 'present',
:source => 'http://apt.puppetlabs.com/pubkey.gpg',
:server => 'pgp.mit.edu',
- :content => params[:key_content],
+ :content => params[:content],
:options => 'debug',
})
end
context "domain with dash" do
let(:params) do{
- :key_server => 'p-gp.m-it.edu',
+ :server => 'p-gp.m-it.edu',
} end
it 'contains the apt_key' do
is_expected.to contain_apt_key(title).with({
context "url" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu',
+ :server => 'hkp://pgp.mit.edu',
}
end
it 'contains the apt_key' do
context "url with port number" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu:80',
+ :server => 'hkp://pgp.mit.edu:80',
}
end
it 'contains the apt_key' do
describe 'validation' do
context "domain begin with dash" do
let(:params) do{
- :key_server => '-pgp.mit.edu',
+ :server => '-pgp.mit.edu',
} end
it 'fails' do
expect { subject.call } .to raise_error(/does not match/)
context "domain begin with dot" do
let(:params) do{
- :key_server => '.pgp.mit.edu',
+ :server => '.pgp.mit.edu',
} end
it 'fails' do
expect { subject.call } .to raise_error(/does not match/)
context "domain end with dot" do
let(:params) do{
- :key_server => "pgp.mit.edu.",
+ :server => "pgp.mit.edu.",
} end
it 'fails' do
expect { subject.call } .to raise_error(/does not match/)
context "exceed character url" do
let :params do
{
- :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+ :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
}
end
it 'fails' do
context "incorrect port number url" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu:8008080'
+ :server => 'hkp://pgp.mit.edu:8008080'
}
end
it 'fails' do
context "incorrect protocol for url" do
let :params do
{
- :key_server => 'abc://pgp.mit.edu:80'
+ :server => 'abc://pgp.mit.edu:80'
}
end
it 'fails' do
context "missing port number url" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu:'
+ :server => 'hkp://pgp.mit.edu:'
}
end
it 'fails' do
context "url ending with a dot" do
let :params do
{
- :key_server => 'hkp://pgp.mit.edu.'
+ :server => 'hkp://pgp.mit.edu.'
}
end
it 'fails' do
end
context "url begin with a dash" do
let(:params) do{
- :key_server => "hkp://-pgp.mit.edu",
+ :server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
expect { subject.call }.to raise_error(/does not match/)
context 'invalid source' do
let :params do {
- :key_source => 'afp://puppetlabs.com/key.gpg',
+ :source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
expect { subject.call }.to raise_error(/does not match/)
context 'invalid content' do
let :params do {
- :key_content => [],
+ :content => [],
} end
it 'fails' do
- expect { subject.call }.to raise_error(/expects a String value/)
+ expect { subject.call }.to raise_error(/expects a/)
end
end
context 'invalid server' do
let :params do {
- :key_server => 'two bottles of rum',
+ :server => 'two bottles of rum',
} end
it 'fails' do
expect { subject.call }.to raise_error(/does not match/)
context 'invalid keyserver_options' do
let :params do {
- :key_options => {},
+ :options => {},
} end
it 'fails' do
- expect { subject.call }.to raise_error(/expects a String value/)
+ expect { subject.call }.to raise_error(/expects a/)
end
end
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
- "#{super()}\napt::key { 'duplicate': key => '#{title}', }"
+ "#{super()}\napt::key { 'duplicate': id => '#{title}', }"
end
it 'contains the duplicate apt::key resource' do
is_expected.to contain_apt__key('duplicate').with({
- :key => title,
+ :id => title,
:ensure => 'present',
})
end
context 'two apt::key resources, different ensure' do
let :pre_condition do
- "#{super()}\napt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+ "#{super()}\napt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
expect { subject.call }.to raise_error(/already ensured as absent/)
:content => [],
} end
it 'fails' do
- expect { subject.call }.to raise_error(/expects a String value/)
+ expect { subject.call }.to raise_error(/expects a/)
end
end
:options => {},
} end
it 'fails' do
- expect { subject.call }.to raise_error(/expects a String value/)
+ expect { subject.call }.to raise_error(/expects a/)
end
end
it do
expect {
subject.call
- }.to raise_error(Puppet::Error, /expects a value of type Integer/)
+ }.to raise_error(Puppet::Error, /expects an Integer value, got String/)
end
end
let :params do
{
- 'include_deb' => false,
- 'include_src' => true,
+ 'include' => { 'deb' => false, 'src' => true },
'location' => 'http://debian.mirror.iweb.ca/debian/',
}
end
end
let :params do
{
- 'comment' => 'foo',
- 'location' => 'http://debian.mirror.iweb.ca/debian/',
- 'release' => 'sid',
- 'repos' => 'testing',
- 'include_src' => false,
- 'required_packages' => 'vim',
- 'key' => GPG_KEY_ID,
- 'key_server' => 'pgp.mit.edu',
- 'key_content' => 'GPG key content',
- 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
- 'pin' => '10',
- 'architecture' => 'x86_64',
- 'trusted_source' => true,
+ 'comment' => 'foo',
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'sid',
+ 'repos' => 'testing',
+ 'include' => { 'src' => false },
+ 'key' => GPG_KEY_ID,
+ 'pin' => '10',
+ 'architecture' => 'x86_64',
+ 'allow_unsigned' => true,
}
end
})
}
- it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
- 'command' => '/usr/bin/apt-get -y install vim',
- 'logoutput' => 'on_failure',
- 'refreshonly' => true,
- 'tries' => '3',
- 'try_sleep' => '1',
- })
- }
-
it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
'ensure' => 'present',
'id' => GPG_KEY_ID,
- 'key_server' => 'pgp.mit.edu',
- 'key_content' => 'GPG key content',
- 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
})
}
end
- context 'trusted_source true' do
+ context 'allow_unsigned true' do
let :facts do
{
:os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
end
let :params do
{
- 'include_src' => false,
+ 'include' => {'src' => false},
'location' => 'http://debian.mirror.iweb.ca/debian/',
- 'trusted_source' => true,
+ 'allow_unsigned' => true,
}
end
let :params do
{
:location => 'hello.there',
- :include => {'deb' => false, 'src' => true,},
+ :include => {'deb' => false, 'src' => true},
:architecture => 'x86_64',
}
end
let :params do
{
:location => 'hello.there',
- :include_src => true,
+ :include => {'src' => true},
}
end
}
end
- context 'include_deb => false' do
+ context 'include deb => false' do
let :facts do
{
:os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
end
let :params do
{
+ :include => { 'deb' => false },
:location => 'hello.there',
- :include_deb => false,
}
end
it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
end
- context 'include_src => true and include_deb => false' do
+ context 'include src => true and include deb => false' do
let :facts do
{
:os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
end
let :params do
{
+ :include => { 'deb' => false, 'src' => true },
:location => 'hello.there',
- :include_deb => false,
- :include_src => true,
- }
- end
-
- it { is_expected.to contain_apt__setting('list-my_source').with({
- :ensure => 'present',
- }).with_content(/deb-src hello.there wheezy main\n/)
- }
- it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
- end
-
- context 'include precedence' do
- let :facts do
- {
- :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
- :lsbdistid => 'debian',
- :lsbdistcodename => 'wheezy',
- :osfamily => 'debian',
- :puppetversion => Puppet.version,
- }
- end
- let :params do
- {
- :location => 'hello.there',
- :include_deb => true,
- :include_src => false,
- :include => { 'deb' => false, 'src' => true },
}
end