Merge pull request #447 from puppetlabs/daenney/hulk-smash-2
It's been a long time - how have you been
This commit is contained in:
commit
396036892d
12 changed files with 478 additions and 269 deletions
|
@ -62,7 +62,7 @@ Puppet::Type.newtype(:apt_key) do
|
|||
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
|
||||
|
||||
|
|
|
@ -1,24 +1,51 @@
|
|||
#
|
||||
class apt(
|
||||
$proxy = {},
|
||||
$always_apt_update = false,
|
||||
$apt_update_frequency = 'reluctantly',
|
||||
$purge_sources_list = false,
|
||||
$purge_sources_list_d = false,
|
||||
$purge_preferences = false,
|
||||
$purge_preferences_d = false,
|
||||
$update_timeout = undef,
|
||||
$update_tries = undef,
|
||||
$sources = undef,
|
||||
$update = {},
|
||||
$purge = {},
|
||||
$proxy = {},
|
||||
$sources = {},
|
||||
$keys = {},
|
||||
$ppas = {},
|
||||
$settings = {},
|
||||
) inherits ::apt::params {
|
||||
|
||||
$frequency_options = ['always','daily','weekly','reluctantly']
|
||||
validate_hash($update)
|
||||
if $update['frequency'] {
|
||||
validate_re($update['frequency'], $frequency_options)
|
||||
}
|
||||
if $update['always'] {
|
||||
validate_bool($update['always'])
|
||||
}
|
||||
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
|
||||
|
||||
$frequency_options = ['always','daily','weekly','reluctantly']
|
||||
validate_re($apt_update_frequency, $frequency_options)
|
||||
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'])
|
||||
}
|
||||
|
||||
validate_bool($purge_sources_list, $purge_sources_list_d,
|
||||
$purge_preferences, $purge_preferences_d)
|
||||
$_purge = merge($::apt::purge_defaults, $purge)
|
||||
|
||||
validate_hash($proxy)
|
||||
if $proxy['host'] {
|
||||
|
@ -35,6 +62,11 @@ class apt(
|
|||
|
||||
$_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',
|
||||
|
@ -42,12 +74,17 @@ class apt(
|
|||
}
|
||||
}
|
||||
|
||||
$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['always'] {
|
||||
Exec <| title=='apt_update' |> {
|
||||
refreshonly => false,
|
||||
}
|
||||
|
@ -59,7 +96,7 @@ class apt(
|
|||
}
|
||||
|
||||
file { 'sources.list':
|
||||
ensure => present,
|
||||
ensure => file,
|
||||
path => $::apt::sources_list,
|
||||
owner => root,
|
||||
group => root,
|
||||
|
@ -73,16 +110,19 @@ class apt(
|
|||
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 => $::apt::preferences,
|
||||
}
|
||||
file { 'preferences':
|
||||
ensure => $preferences_ensure,
|
||||
path => $::apt::preferences,
|
||||
owner => root,
|
||||
group => root,
|
||||
mode => '0644',
|
||||
notify => Exec['apt_update'],
|
||||
}
|
||||
|
||||
file { 'preferences.d':
|
||||
|
@ -90,8 +130,10 @@ class apt(
|
|||
path => $::apt::preferences_d,
|
||||
owner => root,
|
||||
group => root,
|
||||
purge => $purge_preferences_d,
|
||||
recurse => $purge_preferences_d,
|
||||
mode => '0644',
|
||||
purge => $_purge['preferences.d'],
|
||||
recurse => $_purge['preferences.d'],
|
||||
notify => Exec['apt_update'],
|
||||
}
|
||||
|
||||
# Need anchor to provide containment for dependencies.
|
||||
|
@ -100,8 +142,19 @@ class apt(
|
|||
}
|
||||
|
||||
# manage sources if present
|
||||
if $sources != undef {
|
||||
validate_hash($sources)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*key*]
|
||||
# [*id*]
|
||||
# _default_: +$title+, the title/name of the resource
|
||||
#
|
||||
# Is a GPG key ID or full key fingerprint. This value is validated with
|
||||
|
@ -23,14 +23,14 @@
|
|||
# * +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
|
||||
|
@ -38,80 +38,78 @@
|
|||
# * +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": }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ class apt::params {
|
|||
$conf_d = "${root}/apt.conf.d"
|
||||
$preferences = "${root}/preferences"
|
||||
$preferences_d = "${root}/preferences.d"
|
||||
$keyserver = 'keyserver.ubuntu.com'
|
||||
|
||||
if $::osfamily != 'Debian' {
|
||||
fail('This module only works on Debian or derivatives like Ubuntu')
|
||||
|
@ -31,12 +32,33 @@ class apt::params {
|
|||
}
|
||||
}
|
||||
|
||||
$update_defaults = {
|
||||
'always' => false,
|
||||
'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,
|
||||
}
|
||||
|
||||
$source_key_defaults = {
|
||||
'server' => $keyserver,
|
||||
'options' => undef,
|
||||
'content' => undef,
|
||||
'source' => undef,
|
||||
}
|
||||
|
||||
$file_defaults = {
|
||||
'owner' => 'root',
|
||||
'group' => 'root',
|
||||
|
|
|
@ -10,8 +10,8 @@ define apt::ppa(
|
|||
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')
|
||||
|
|
|
@ -9,20 +9,30 @@ define apt::source(
|
|||
$include_src = false,
|
||||
$include_deb = true,
|
||||
$key = undef,
|
||||
$key_server = 'keyserver.ubuntu.com',
|
||||
$key_content = undef,
|
||||
$key_source = undef,
|
||||
$pin = false,
|
||||
$architecture = undef,
|
||||
$trusted_source = false,
|
||||
) {
|
||||
validate_string($architecture, $comment, $location, $release, $repos, $key_server)
|
||||
validate_string($architecture, $comment, $location, $release, $repos)
|
||||
validate_bool($trusted_source, $include_src, $include_deb)
|
||||
|
||||
if ! $release {
|
||||
fail('lsbdistcodename fact not available: release parameter required')
|
||||
}
|
||||
|
||||
$_before = Apt::Setting["list-${title}"]
|
||||
|
||||
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 {
|
||||
validate_string($key)
|
||||
}
|
||||
}
|
||||
|
||||
apt::setting { "list-${name}":
|
||||
ensure => $ensure,
|
||||
content => template('apt/_header.erb', 'apt/source.list.erb'),
|
||||
|
@ -36,20 +46,29 @@ define apt::source(
|
|||
apt::pin { $name:
|
||||
ensure => $ensure,
|
||||
priority => $pin,
|
||||
before => Apt::Setting["list-${name}"],
|
||||
before => $_before,
|
||||
origin => $host,
|
||||
}
|
||||
}
|
||||
|
||||
# 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 => Apt::Setting["list-${name}"],
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ class apt::update {
|
|||
#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 $::apt::_update['always'] == false {
|
||||
#if always_apt_update is true there's no point in parsing this logic.
|
||||
|
||||
case $apt::apt_update_frequency {
|
||||
case $::apt::_update['frequency'] {
|
||||
'always': {
|
||||
$_kick_apt = true
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ class apt::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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ describe 'apt' do
|
|||
|
||||
context 'defaults' do
|
||||
it { is_expected.to 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]',
|
||||
:ensure => 'file',
|
||||
:path => '/etc/apt/sources.list',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:mode => '0644',
|
||||
:content => "# Repos managed by puppet.\n",
|
||||
:notify => 'Exec[apt_update]',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
|
||||
|
@ -17,18 +18,30 @@ describe 'apt' do
|
|||
:path => '/etc/apt/sources.list.d',
|
||||
:owner => 'root',
|
||||
:group => 'root',
|
||||
:purge => false,
|
||||
:recurse => false,
|
||||
:mode => '0644',
|
||||
:purge => true,
|
||||
:recurse => true,
|
||||
:notify => 'Exec[apt_update]',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_file('preferences.d').only_with({
|
||||
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 { 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',
|
||||
:purge => false,
|
||||
:recurse => false,
|
||||
:mode => '0644',
|
||||
:purge => true,
|
||||
:recurse => true,
|
||||
:notify => 'Exec[apt_update]',
|
||||
})}
|
||||
|
||||
it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
|
||||
|
@ -83,39 +96,34 @@ describe 'apt' do
|
|||
context 'lots of non-defaults' do
|
||||
let :params do
|
||||
{
|
||||
:always_apt_update => true,
|
||||
:purge_sources_list => true,
|
||||
:purge_sources_list_d => true,
|
||||
:purge_preferences => true,
|
||||
:purge_preferences_d => true,
|
||||
:update_timeout => '1',
|
||||
:update_tries => '3',
|
||||
:update => { 'always' => true, 'timeout' => 1, 'tries' => 3 },
|
||||
:purge => { 'sources.list' => false, 'sources.list.d' => false,
|
||||
'preferences' => false, 'preferences.d' => false, },
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_file('sources.list').with({
|
||||
:content => "# Repos managed by puppet.\n"
|
||||
it { is_expected.to contain_file('sources.list').without({
|
||||
:content => "# Repos managed by puppet.\n",
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_file('sources.list.d').with({
|
||||
:purge => 'true',
|
||||
:recurse => 'true',
|
||||
:purge => false,
|
||||
:recurse => false,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_file('apt-preferences').only_with({
|
||||
:ensure => 'absent',
|
||||
:path => '/etc/apt/preferences',
|
||||
it { is_expected.to contain_file('preferences').with({
|
||||
:ensure => 'file',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_file('preferences.d').with({
|
||||
:purge => 'true',
|
||||
:recurse => 'true',
|
||||
:purge => false,
|
||||
:recurse => false,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('apt_update').with({
|
||||
:refreshonly => 'false',
|
||||
:timeout => '1',
|
||||
:tries => '3',
|
||||
:refreshonly => false,
|
||||
:timeout => 1,
|
||||
:tries => 3,
|
||||
})}
|
||||
|
||||
end
|
||||
|
@ -132,16 +140,14 @@ describe 'apt' do
|
|||
'location' => 'http://debian.mirror.iweb.ca/debian/',
|
||||
'release' => 'unstable',
|
||||
'repos' => 'main contrib non-free',
|
||||
'key' => '55BE302B',
|
||||
'key_server' => 'subkeys.pgp.net',
|
||||
'key' => { 'id' => '55BE302B', 'server' => 'subkeys.pgp.net' },
|
||||
'pin' => '-10',
|
||||
'include_src' => true,
|
||||
},
|
||||
'puppetlabs' => {
|
||||
'location' => 'http://apt.puppetlabs.com',
|
||||
'repos' => 'main',
|
||||
'key' => '4BD6EC30',
|
||||
'key_server' => 'pgp.mit.edu',
|
||||
'key' => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' },
|
||||
}
|
||||
} } }
|
||||
|
||||
|
@ -163,13 +169,66 @@ describe 'apt' do
|
|||
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 {
|
||||
is_expected.to compile
|
||||
|
@ -177,12 +236,8 @@ describe 'apt' do
|
|||
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 {
|
||||
is_expected.to compile
|
||||
|
@ -190,12 +245,8 @@ describe 'apt' do
|
|||
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 {
|
||||
is_expected.to compile
|
||||
|
@ -203,12 +254,8 @@ describe 'apt' do
|
|||
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 {
|
||||
is_expected.to compile
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'apt::update', :type => :class do
|
||||
context 'when apt::always_apt_update is true' do
|
||||
context "when update['always']=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}" }
|
||||
let (:pre_condition) { "class{'::apt': update => {'always' => true},}" }
|
||||
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
|
||||
['always','daily','weekly','reluctantly'].each do |update_frequency|
|
||||
context "when apt::apt_update_frequency has the value of #{update_frequency}" do
|
||||
context "when 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}' }" }
|
||||
let (:pre_condition) { "class{'::apt': update => {'always' => true, '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})
|
||||
|
@ -23,7 +23,7 @@ describe 'apt::update', :type => :class do
|
|||
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}' }" }
|
||||
let (:pre_condition) { "class{'::apt': update => {'always' => true, '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})
|
||||
|
@ -34,12 +34,12 @@ describe 'apt::update', :type => :class do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when apt::always_apt_update is false' do
|
||||
context "and apt::apt_update_frequency has the value of always" do
|
||||
context "when apt::update['always']=false" do
|
||||
context "and apt::update['frequency']='always'" do
|
||||
{ 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
|
||||
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' }" }
|
||||
let (:pre_condition) { "class{'::apt': update => {'always' => false, '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})
|
||||
|
@ -48,18 +48,18 @@ describe 'apt::update', :type => :class do
|
|||
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' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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 "and apt::apt_update_frequency has the value of reluctantly" do
|
||||
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} }
|
||||
let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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})
|
||||
|
@ -68,7 +68,7 @@ describe 'apt::update', :type => :class do
|
|||
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' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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})
|
||||
|
@ -76,11 +76,11 @@ describe 'apt::update', :type => :class do
|
|||
end
|
||||
end
|
||||
['daily','weekly'].each do |update_frequency|
|
||||
context "and apt::apt_update_frequency has the value of #{update_frequency}" do
|
||||
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 => '#{update_frequency}' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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})
|
||||
|
@ -89,7 +89,7 @@ describe 'apt::update', :type => :class do
|
|||
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}' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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)
|
||||
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
|
||||
|
@ -97,7 +97,7 @@ describe 'apt::update', :type => :class do
|
|||
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}' }" }
|
||||
let (:pre_condition) { "class{ '::apt': update => {'always' => false, '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})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'apt::key', :type => :define do
|
||||
describe 'apt::key' do
|
||||
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
|
||||
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
|
||||
|
||||
|
@ -12,12 +12,12 @@ describe 'apt::key', :type => :define do
|
|||
describe 'default options' do
|
||||
it 'contains the apt_key' do
|
||||
is_expected.to contain_apt_key(title).with({
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:keyserver_options => nil,
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:options => nil,
|
||||
})
|
||||
end
|
||||
it 'contains the apt_key present anchor' do
|
||||
|
@ -31,17 +31,17 @@ describe 'apt::key', :type => :define do
|
|||
end
|
||||
|
||||
let :params do {
|
||||
:key => GPG_KEY_ID,
|
||||
:id => GPG_KEY_ID,
|
||||
} end
|
||||
|
||||
it 'contains the apt_key' do
|
||||
is_expected.to contain_apt_key(title).with({
|
||||
:id => GPG_KEY_ID,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:keyserver_options => nil,
|
||||
:id => GPG_KEY_ID,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:options => nil,
|
||||
})
|
||||
end
|
||||
it 'contains the apt_key present anchor' do
|
||||
|
@ -56,12 +56,12 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
it 'contains the apt_key' do
|
||||
is_expected.to contain_apt_key(title).with({
|
||||
:id => title,
|
||||
:ensure => 'absent',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:keyserver_options => nil,
|
||||
:id => title,
|
||||
:ensure => 'absent',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:keyserver => nil,
|
||||
})
|
||||
end
|
||||
it 'contains the apt_key absent anchor' do
|
||||
|
@ -71,20 +71,20 @@ describe 'apt::key', :type => :define 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
|
||||
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[:key_content],
|
||||
:keyserver_options => 'debug',
|
||||
: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
|
||||
|
@ -94,7 +94,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
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({
|
||||
|
@ -107,7 +107,7 @@ describe 'apt::key', :type => :define do
|
|||
context "url" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgp.mit.edu',
|
||||
:server => 'hkp://pgp.mit.edu',
|
||||
}
|
||||
end
|
||||
it 'contains the apt_key' do
|
||||
|
@ -120,7 +120,7 @@ describe 'apt::key', :type => :define do
|
|||
context "url with port number" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgp.mit.edu:80',
|
||||
:server => 'hkp://pgp.mit.edu:80',
|
||||
}
|
||||
end
|
||||
it 'contains the apt_key' do
|
||||
|
@ -135,7 +135,7 @@ describe 'apt::key', :type => :define do
|
|||
describe 'validation' do
|
||||
context "domain begin with dash" do
|
||||
let(:params) do{
|
||||
:key_server => '-pgp.mit.edu',
|
||||
:server => '-pgp.mit.edu',
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject } .to raise_error(/does not match/)
|
||||
|
@ -144,7 +144,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context "domain begin with dot" do
|
||||
let(:params) do{
|
||||
:key_server => '.pgp.mit.edu',
|
||||
:server => '.pgp.mit.edu',
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject } .to raise_error(/does not match/)
|
||||
|
@ -153,7 +153,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context "domain end with dot" do
|
||||
let(:params) do{
|
||||
:key_server => "pgp.mit.edu.",
|
||||
:server => "pgp.mit.edu.",
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject } .to raise_error(/does not match/)
|
||||
|
@ -162,7 +162,7 @@ describe 'apt::key', :type => :define do
|
|||
context "exceed character url" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
|
||||
:server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
|
||||
}
|
||||
end
|
||||
it 'fails' do
|
||||
|
@ -172,7 +172,7 @@ describe 'apt::key', :type => :define do
|
|||
context "incorrect port number url" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgp.mit.edu:8008080'
|
||||
:server => 'hkp://pgp.mit.edu:8008080'
|
||||
}
|
||||
end
|
||||
it 'fails' do
|
||||
|
@ -182,7 +182,7 @@ describe 'apt::key', :type => :define do
|
|||
context "incorrect protocol for url" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'abc://pgp.mit.edu:80'
|
||||
:server => 'abc://pgp.mit.edu:80'
|
||||
}
|
||||
end
|
||||
it 'fails' do
|
||||
|
@ -192,7 +192,7 @@ describe 'apt::key', :type => :define do
|
|||
context "missing port number url" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgp.mit.edu:'
|
||||
:server => 'hkp://pgp.mit.edu:'
|
||||
}
|
||||
end
|
||||
it 'fails' do
|
||||
|
@ -202,7 +202,7 @@ describe 'apt::key', :type => :define do
|
|||
context "url ending with a dot" do
|
||||
let :params do
|
||||
{
|
||||
:key_server => 'hkp://pgp.mit.edu.'
|
||||
:server => 'hkp://pgp.mit.edu.'
|
||||
}
|
||||
end
|
||||
it 'fails' do
|
||||
|
@ -211,7 +211,7 @@ describe 'apt::key', :type => :define do
|
|||
end
|
||||
context "url begin with a dash" do
|
||||
let(:params) do{
|
||||
:key_server => "hkp://-pgp.mit.edu",
|
||||
:server => "hkp://-pgp.mit.edu",
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject }.to raise_error(/does not match/)
|
||||
|
@ -228,7 +228,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context 'invalid source' do
|
||||
let :params do {
|
||||
:key_source => 'afp://puppetlabs.com/key.gpg',
|
||||
:source => 'afp://puppetlabs.com/key.gpg',
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject }.to raise_error(/does not match/)
|
||||
|
@ -237,7 +237,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context 'invalid content' do
|
||||
let :params do {
|
||||
:key_content => [],
|
||||
:content => [],
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject }.to raise_error(/is not a string/)
|
||||
|
@ -246,16 +246,16 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context 'invalid server' do
|
||||
let :params do {
|
||||
:key_server => 'two bottles of rum',
|
||||
:server => 'two bottles of rum',
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject }.to raise_error(/does not match/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid keyserver_options' do
|
||||
context 'invalid options' do
|
||||
let :params do {
|
||||
:key_options => {},
|
||||
:options => {},
|
||||
} end
|
||||
it 'fails' do
|
||||
expect { subject }.to raise_error(/is not a string/)
|
||||
|
@ -276,28 +276,28 @@ describe 'apt::key', :type => :define do
|
|||
describe 'duplication' do
|
||||
context 'two apt::key resources for same key, different titles' do
|
||||
let :pre_condition do
|
||||
"apt::key { 'duplicate': key => '#{title}', }"
|
||||
"apt::key { 'duplicate': id => '#{title}', }"
|
||||
end
|
||||
|
||||
it 'contains two apt::key resources' do
|
||||
is_expected.to contain_apt__key('duplicate').with({
|
||||
:key => title,
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
})
|
||||
is_expected.to contain_apt__key(title).with({
|
||||
:key => title,
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
})
|
||||
end
|
||||
|
||||
it 'contains only a single apt_key' do
|
||||
is_expected.to contain_apt_key('duplicate').with({
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:keyserver_options => nil,
|
||||
:id => title,
|
||||
:ensure => 'present',
|
||||
:source => nil,
|
||||
:server => nil,
|
||||
:content => nil,
|
||||
:options => nil,
|
||||
})
|
||||
is_expected.not_to contain_apt_key(title)
|
||||
end
|
||||
|
@ -305,7 +305,7 @@ describe 'apt::key', :type => :define do
|
|||
|
||||
context 'two apt::key resources, different ensure' do
|
||||
let :pre_condition do
|
||||
"apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
|
||||
"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/)
|
||||
|
|
|
@ -214,7 +214,7 @@ describe 'apt::ppa' do
|
|||
it do
|
||||
expect {
|
||||
is_expected.to compile
|
||||
}.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)
|
||||
}.to raise_error(Puppet::Error, /supported on Ubuntu and LinuxMint only/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'apt::source', :type => :define do
|
||||
describe 'apt::source' do
|
||||
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
|
||||
|
||||
let :pre_condition do
|
||||
|
@ -22,18 +22,19 @@ describe 'apt::source', :type => :define do
|
|||
|
||||
let :params do
|
||||
{
|
||||
'include_deb' => false,
|
||||
'include_src' => true,
|
||||
:include_deb => false,
|
||||
:include_src => true,
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__setting('list-my_source').with({
|
||||
'ensure' => 'present',
|
||||
:ensure => 'present',
|
||||
}).with_content(/# my_source\ndeb-src wheezy main\n/)
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
context 'no defaults' do
|
||||
describe 'no defaults' do
|
||||
let :facts do
|
||||
{
|
||||
:lsbdistid => 'Debian',
|
||||
|
@ -41,43 +42,112 @@ describe 'apt::source', :type => :define do
|
|||
:osfamily => 'Debian'
|
||||
}
|
||||
end
|
||||
let :params do
|
||||
{
|
||||
'comment' => 'foo',
|
||||
'location' => 'http://debian.mirror.iweb.ca/debian/',
|
||||
'release' => 'sid',
|
||||
'repos' => 'testing',
|
||||
'include_src' => false,
|
||||
'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',
|
||||
:include_src => false,
|
||||
:key => GPG_KEY_ID,
|
||||
:pin => '10',
|
||||
:architecture => 'x86_64',
|
||||
:trusted_source => 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_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/)
|
||||
}
|
||||
context 'with complex key' do
|
||||
let :params do
|
||||
{
|
||||
:comment => 'foo',
|
||||
:location => 'http://debian.mirror.iweb.ca/debian/',
|
||||
:release => 'sid',
|
||||
:repos => 'testing',
|
||||
:include_src => false,
|
||||
: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',
|
||||
:trusted_source => true,
|
||||
}
|
||||
end
|
||||
|
||||
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__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__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').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__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,
|
||||
: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',
|
||||
:include_src => false,
|
||||
:key => GPG_KEY_ID,
|
||||
:pin => '10',
|
||||
:architecture => 'x86_64',
|
||||
:trusted_source => 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
|
||||
|
@ -90,13 +160,13 @@ describe 'apt::source', :type => :define do
|
|||
end
|
||||
let :params do
|
||||
{
|
||||
'include_src' => false,
|
||||
'trusted_source' => true,
|
||||
:include_src => false,
|
||||
:trusted_source => true,
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__setting('list-my_source').with({
|
||||
'ensure' => 'present',
|
||||
:ensure => 'present',
|
||||
}).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
|
||||
}
|
||||
end
|
||||
|
@ -111,18 +181,18 @@ describe 'apt::source', :type => :define do
|
|||
end
|
||||
let :params do
|
||||
{
|
||||
'include_deb' => false,
|
||||
'include_src' => true,
|
||||
'architecture' => 'x86_64',
|
||||
:include_deb => false,
|
||||
:include_src => true,
|
||||
:architecture => 'x86_64',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__setting('list-my_source').with({
|
||||
'ensure' => 'present',
|
||||
:ensure => 'present',
|
||||
}).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
context 'ensure => absent' do
|
||||
let :facts do
|
||||
{
|
||||
|
@ -133,12 +203,12 @@ describe 'apt::source', :type => :define do
|
|||
end
|
||||
let :params do
|
||||
{
|
||||
'ensure' => 'absent',
|
||||
:ensure => 'absent',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_apt__setting('list-my_source').with({
|
||||
'ensure' => 'absent'
|
||||
:ensure => 'absent'
|
||||
})
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue